1
A
回答
1
DateTime.UtcNow是C#(.NET):)
对于Java,你可以看看这个答案:
How can I get the current date and time in UTC or GMT in Java?
:
SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss");
dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT"));
//Local time zone
SimpleDateFormat dateFormatLocal = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss");
//Time in GMT
return dateFormatLocal.parse(dateFormatGmt.format(new Date()));
3
可以使用如下:
DateTime.now(DateTimeZone.UTC);
来自javadoc:
在指定时区中使用ISOChronology获取设置为当前系统毫秒时间的DateTime。
1
你可以尝试这样的:
DateTime utc = new DateTime(DateTimeZone.UTC);
//If you want to get the time for a specific timezone then add it
DateTimeZone tz = DateTimeZone.forID("America/Los_Angeles");
DateTime dt = utc.toDateTime(tz);
相关问题
- 1. 日期时间添加时间段而不显示日期VB
- 2. 水晶报告 - 日期时间组头不显示时间,只有日期。需要显示日期和时间
- 3. 显示日期时间
- 4. 时间和日期显示
- 5. 显示时间和日期
- 6. 显示日期和时间
- 7. C#日期时间不显示正确
- 8. 显示android日期而不是时间
- 9. 在Python中设置日期时间为utcnow - 30
- 10. 使用日期/时间选取器显示日期/时间Android
- 11. DataTables我如何显示日期而不是日期时间
- 12. Python日期时间对象不显示正确日期
- 13. TWIG日期函数显示不正确的日期时间
- 14. JSP显示日期时间而不是日期
- 15. 显示日期和时间而不是日期?
- 16. ChartJS在时间轴上显示标签时显示日期但不是时间
- 17. 显示日期但不显示时间的单元格
- 18. PHP - 日期时间 - 显示时间ET而不是EST或EDT
- 19. 显示当前日期时间不是以前的时间vb.net
- 20. 显示正确的日期时间值
- 21. 在UI中显示日期和时间
- 22. ExtJs 4显示WCF日期时间
- 23. 使用Apex显示日期时间:outputtext
- 24. 日期和时间循环显示
- 25. NSDate关于日期和时间显示
- 26. 日期时间显示问题
- 27. 在JTable中显示MySQL日期时间
- 28. TextBoxFor显示没有时间的日期
- 29. PHP日期显示来自时间戳
- 30. 显示日期和时间像博客
感谢....也可以请您告诉我 “滴答” 也为C#。 –
肯定:)这个答案:http://stackoverflow.com/questions/3706306/c-sharp-datetime-ticks-equivalent-in-java – Jurion
@ChiragNangru: - 是[蜱是C#](https:// msdn。 microsoft.com/en-us/library/system.datetime.ticks(v=vs.110).aspx)。 –