62,614
社区成员
发帖
与我相关
我的任务
分享
import java.text.DateFormat;
import java.text.SimpleDateFormat;
public class Test {
public static void main(String args[]) throws Exception {
String[] dateString = { "1900-01-01 07:59:59", "1900-01-01 08:00:00",
"1900-01-01 08:05:51", "1900-01-01 08:05:52" };
DateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
for (String date : dateString) {
System.out.println(date + "=" + dateTimeFormat.parse(date));
}
}
}
String[] dateString = {
"1900-01-01 08:00:00",
"1900-01-01 08:00:01", "1900-01-01 08:05:52",
"1900-01-01 08:05:53" };
DateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
for (String date : dateString) {
System.out.println(date + "=" + dateTimeFormat.parse(date).toGMTString());
}
1900-01-01 08:00:00=1 Jan 1900 00:00:00 GMT
1900-01-01 08:00:01=1 Jan 1900 00:00:01 GMT
1900-01-01 08:05:52=1 Jan 1900 00:00:00 GMT
1900-01-01 08:05:53=1 Jan 1900 00:00:01 GMT