Java????????????????
???????????? ???????[ 2013/2/4 10:08:10 ] ????????
???????java?е??????????????????????????Date??Calendar??SimpleDateFormat???????????????????????????????????????TimeZone?????????
????????????????????????????8??С????????????????TimeZone?????????????????TimeZone????????????????????????????
???????TimeZone???????
????1????????????????á?
????2????????????????á?
????????????????????????????????????????????????п????????????????????????????JVM???????????????????????????á??????????к????????ú?????????磺
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
????????????????ò????????????????????????????
?????? ??SimpleDateFormat????????£?
public static void main(String[] args) {
Date date = new Date(1359641834000L);// 2013-1-31 22:17:14
String dateStr = "2013-1-31 22:17:14";
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
try {
Date dateTmp = dateFormat.parse(dateStr);
System.out.println(dateTmp);
} catch (ParseException e) {
e.printStackTrace();
}
String dateStrTmp = dateFormat.format(date);
System.out.println(dateStrTmp);
}
???????н????
Fri Feb 01 06:17:14 CST 2013
2013-01-31 14:17:14
??????????????????????????????г?????????????????????????????????????ж?????????????????????????????????"Asia/Shanghai"????GMT+8??????????????????????????format??????????????????????????????????????2013-1-31 22:17:14???????????????GMT?????????????8??С????????????????????parse??????????????????????????????????2013-1-31 22:17:14???GMT??UTC?????ps???????????????????GMT??????????????????????????????????"Asia/Shanghai"??????????8??С???
?????? ??Calendar????????£?
public static void main(String[] args) {
Date date = new Date(1359641834000L);// 2013-1-31 22:17:14
System.out.println(date);
Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
// ??????? Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
calendar.setTime(date);
System.out.println(calendar.get(Calendar.HOUR_OF_DAY) + ":" + calendar.get(Calendar.MINUTE));
}
???????н????
Thu Jan 31 22:17:14 CST 2013
14:17
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11