JAVA-- time format conversion

String to parse used to date, with the date format converted into String

Set the date format with SimpleDateFormat

formatter = new SimpleDateFormat( "yyyy-MM-dd ");
String date = formatter.format(new Date());
formatter = new SimpleDateFormat( "yyyy-MM-dd ");
String s = "2011-07-09 "; 
Date date = formatter.parse(s);

 

Guess you like

Origin www.cnblogs.com/heyjia/p/11242040.html