AUTO TRENDS

You can get the latest Automobile new's and the latest and upcoming models of BMW,Mercedez Benz,Toyota,Hyundai,Tata..
Popular Technology Articles

Get Latest Tech News, Updates

convert string date format to other

Posted by Tharadas179 Thursday, September 3, 2009

import java.util.*;
import java.text.*;
public class StringToDate {
public static void main(String[] args) {
try {
String str_date="10-Sep-2009";
DateFormat formatter,formatter2 ;
Date date ;
formatter = new SimpleDateFormat("dd-MMM-yyyy");
date = (Date)formatter.parse(str_date);

String formattedDate = formatter.format(date);
System.out.println("dd-MMM-yyyy date is ==>"+formattedDate);
Date date1 = formatter.parse(formattedDate);

formatter = new SimpleDateFormat("yyyy-MM-dd");
formattedDate = formatter.format(date1);
System.out.println("yyyy-mm-dd date is ==>"+formattedDate);
}
catch(Exception e)

{System.out.println("Exception :"+e); }

}
}

0 comments

Post a Comment