String ds = "Thu, 05 Sep 2002 11:35:12 GMT";
DateFormat df = DateFormat.getDateInstance(int 对应style,Locale.对应时间标准);
//就是在上面的代码中文处设定你的时间对应形式和对应时间标准
//"Thu, 05 Sep 2002 11:35:12 GMT";时间形式应该是0,
//但时间标准格林尼治标准时间我怎么也选不出来……sigh,或许你的jdk中有
try {
Date d = df.parse(ds);
System.out.println("时间是:"+d.toString());
}
catch(ParseException e) {
System.out.println(e);
}
DateFormat df = DateFormat.getDateInstance(int 对应style,Locale.对应时间标准);
//就是在上面的代码中文处设定你的时间对应形式和对应时间标准
//"Thu, 05 Sep 2002 11:35:12 GMT";时间形式应该是0,
//但时间标准格林尼治标准时间我怎么也选不出来……sigh,或许你的jdk中有
try {
Date d = df.parse(ds);
System.out.println("时间是:"+d.toString());
}
catch(ParseException e) {
System.out.println(e);
}
[dd/MMM/yyyy:hh:mm:ss ]
String myString = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, Locale.US) .format(new Date());
System.out.println(myString); Date newdate = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, Locale.US) .parse(myString);
System.out.println(newdate.toString());
}
catch (ParseException ex) {
System.out.println(ex.getMessage());
}输出结果:
Friday, September 6, 2002 1:17:26 PM PDT
Fri Sep 06 13:17:26 PDT 2002
Date newd = new Date(str);
System.out.println(newd.toString());输出结果:Thu Sep 05 04:35:12 PDT 2002