Java 获取UTC时间

原创
2015/02/03 15:43
阅读数 824

几行代码而已,百度上各种代码都有,各种格式,我还是写自己的吧。

import java.util.Date;

public class Main
{

	public static void main(String[] args)
	{
		// TODO Auto-generated method stub

		Date time_now = new Date();
		@SuppressWarnings("deprecation")
		long time_code = Date.UTC(
				time_now.getYear(), 
				time_now.getMonth(),
				time_now.getDate(), 
				time_now.getHours(), 
				time_now.getMinutes(),
				time_now.getSeconds());
		Date time_utc = new Date(time_code); 
		System.out.println(time_utc.toString());
	}
}


展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
0 评论
0 收藏
0
分享
返回顶部
顶部