convert string date format to other



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); }

}
}


Responses

0 Respones to "convert string date format to other"

Post a Comment

 

Recent Comments

Popular Posts

Return to top of page Copyright © 2010 | Platinum Theme Converted into Blogger Template by HackTutors