81,091
社区成员
发帖
与我相关
我的任务
分享
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
public class A3 {
public static void main(String[] args) throws ParseException{
//2011/9/8 15:14:00
String dateStr = "Thu Sep 08 23:14:00 CST 2011";
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy",
Locale.US);
try {
TimeZone tz=TimeZone.getTimeZone( "US/Central ");
sdf.setTimeZone(tz);
Date date= sdf.parse(dateStr);
SimpleDateFormat format1 = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
format1.setTimeZone(TimeZone.getTimeZone( "GMT-8:00 "));
System.out.println(format1.format(date));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}