jvm 在不同的机器上运行,获取标准的中国时间方式如下:
public static void main(String[] args) {
DateFormat dateformat = new SimpleDateFormat("yyyyMMddHHmmss");
System.out.println(dateformat.format(Calendar.getInstance(TimeZone.getTimeZone("GMT+8")).getTime()));
}
本文介绍了一种在各种机器上获取标准中国时间的简单方法,使用Java的Calendar和SimpleDateFormat类来实现。通过设置时区为GMT+8,可以确保输出的时间符合中国的标准时间。
jvm 在不同的机器上运行,获取标准的中国时间方式如下:
public static void main(String[] args) {
DateFormat dateformat = new SimpleDateFormat("yyyyMMddHHmmss");
System.out.println(dateformat.format(Calendar.getInstance(TimeZone.getTimeZone("GMT+8")).getTime()));
}
1万+

被折叠的 条评论
为什么被折叠?