Calendar 获取时间戳的 年 月 日 分 秒
public static void main(String[] args) {
Calendar calendar = Date2Calendar(new Date(Long.parseLong("1679396990395")));
System.out.println("年:"+calendar.get(Calendar.YEAR));
System.out.println("月:"+(calendar.get(Calendar.MONTH)+1));
System.out.println("日:"+calendar.get(Calendar.DAY_OF_MONTH));
System.out.println("时:"+calendar.get(Calendar.HOUR_OF_DAY));
System.out.println("分:"+calendar.get(Calendar.MINUTE));
System.out.println("秒:"+calendar.get(Calendar.SECOND));
}
private static Calendar Date2Calendar(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar;
}