【发布时间】:2011-03-01 08:56:18
【问题描述】:
可能重复:
How can I get the current date and time in UTC or GMT in Java?
我想获取 GMT 的当前时间戳;任何想法如何做到这一点?
我设法得到一个 gmt 格式的字符串 问题是我想将此字符串转换为等效的时间戳对象,即同一时间但作为时间戳对象
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss zzz");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
Date date=new Date();
String s=sdf.format(date);
System.out.println("GMT: "+s);
//need to convert the string to equivalent timestamp object
【问题讨论】: