1.Date 类 java.util.Date是一个"万能接口",它包含日期.时间,还有毫秒数,如果你只想用java.util.Date存储日期,或者只存储时间,那么,只有你知道哪些部分的数据是有用的,哪些部分的数据是不能用的. 1.1 Date的构造方法 Date 是我们使用的最多的一个日期类,Date提供的构造方法在官方API中有一下几种: Date 类提供了多种构造方法,但是目前有很多方法都已经不建议使用 public Date() { this(System.currentTi
struct tm->time() localtime() gmtime() struct tm { int tm_sec; /*代表目前秒数,正常范围为0-59,但允许至61秒 */ int tm_min; /*代表目前分数,范围0-59*/ int tm_hour; /*从午夜算起的时数,范围为0-23*/ int tm_mday; /*目前月份的日数,范围01-31*/ int tm_mon; /*代表目前月份,从一月算起,范围从0-11*/ int tm_year; /*从1900 年算
Java 8中 java.util.Date 类新增了两个方法,分别是from(Instant instant)和toInstant()方法 // Obtains an instance of Date from an Instant object.public static Date from(Instant instant) { try { return new Date(instant.toEpochMilli()); } catch (ArithmeticExc
Linux使用 UTC,但是windows默认使用localtime.解决的办法如下(重启后生效). 进入windows使用regedit写入DWORD值(设置成十六进制"1"): HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\RealTimeIsUniversal Windows XP 和 Windows Vista SP1 支持设置系统时间标准为 UTC ,但是休眠待机的时候会把系统重