|
|
Convert date from one format to another format - JSP/Java
|
Views : 10027
|
|
Tagged in : JSP-Java
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
Hi,
The bellow code will give the solution to format date one form to another form
import java.util.Date;
import java.text.*;
public class Date1
{
public static void main(String args[]) throws Exception{
String strDate = "2008-10-14";
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date dateStr = formatter.parse(strDate);
String formattedDate = formatter.format(dateStr);
System.out.println("yyyy-MM-dd date is ==>"+formattedDate);
Date date1 = formatter.parse(formattedDate);
formatter = new SimpleDateFormat("dd-MMM-yyyy");
formattedDate = formatter.format(date1);
System.out.println("dd-MMM-yyyy date is ==>"+formattedDate);
}
}
the output will be
yyyy-MM-dd date is ==> 2008-10-14
dd-MMM-yyyy date is ==> 14-OCT-2008 |
|
By - Vinoth, On - 2008-10-14 |
|
|
|