Java????????????????
???????????? ???????[ 2013/2/4 10:08:10 ] ????????
????Calendar???漰??????????????????????????SimpleDateFormat???????????????????????·???????????????????????????????????????calendar.getTime()???????Date??????????????????????setTime????????????????????????????????????calendar.get()???????????????????Date????????????
????????????????£?
public static void main(String[] args) {
Date date = new Date(1359641834000L);
System.out.println(date);
Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
// ??????? Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
calendar.setTime(date);
Calendar calendar2 = Calendar.getInstance();
calendar2.set(calendar.get(Calendar.YEAR)?? calendar.get(Calendar.MONTH)?? calendar.get(Calendar.DAY_OF_MONTH)?? calendar.get(Calendar.HOUR_OF_DAY)?? calendar.get(Calendar.MINUTE)?? calendar.get(Calendar.SECOND));
System.out.println(calendar2.getTime());
}
???????н????
Thu Jan 31 22:17:14 CST 2013
Thu Jan 31 14:17:14 CST 2013
?????? ??????????????
?????????????????????????????????????????????????????????????????У?????????????????????????????
public static void main(String[] args) {
Date date = new Date(1359641834000L);
System.out.println(date);
date = changeTimeZone(date?? TimeZone.getTimeZone("Asia/Shanghai")?? TimeZone.getTimeZone("GMT"));
System.out.println(date);
}
/**
* ?????????????????
* @param date ????
* @param oldZone ?????????
* @param newZone ?????????
* @return ????
*/
public static Date changeTimeZone(Date date?? TimeZone oldZone?? TimeZone newZone) {
Date dateTmp = null;
if (date != null) {
int timeOffset = oldZone.getRawOffset() - newZone.getRawOffset();
dateTmp = new Date(date.getTime() - timeOffset);
}
return dateTmp;
}
???????н????
Thu Jan 31 22:17:14 CST 2013
Thu Jan 31 14:17:14 CST 2013
???????????????????????в????????????????е?????????????????????????????java????????????????????????????????????????????????????????jdk?????????????????????jdk???????????????????????????????????????????????????????jdk????????????“????”????????????????????
??????
???·???
??????????????????
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