使用此示例代码我的时间/日期会发生什么?
package date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class DateFormatTest
{
public static void main(String args[]) throws ParseException
{
final String pattern = "dd/MM/YYYY HH:mm";
final Locale locale = Locale.FRENCH;
final SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale);
Date d = new Date();
System.out.println("Today: " + d);
String parsedDate = formatter.format(d);
System.out.println("Today as string:" + parsedDate);
Date d2 = formatter.parse(parsedDate);
System.out.println("Today parsed back:" + d2);
}
}
输出:
Today: Fri Jun 28 16:28:04 CEST 2013
Today as string:28/06/2013 16:28
Today parsed back:Mon Dec 31 16:28:00 CET 2012 >>> ????