Returns String type for JSON
Just format it twice, for example:
Java code
Copy the code code as follows:
String s = "2012-08-25";
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdf2 = new SimpleDateFormat("Yyyy year M month d day");
try {
System.out.println(sdf2.format(sdf1.parse(s)));
} catch (ParseException e) {
// TODO Auto-generated catch block
//www.heatpress123.net
e.printStackTrace();
}
Output: August 25, 2012
Java code
Copy the code code as follows:
String str = "2012/08/25";
SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy/MM/dd");
SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy year MM month dd day");
try {
System.out.println(sdf4.format(sdf3.parse(str)));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Output: August 25, 2012