我想转换String myDate = "2014/10/29 18:10:45"成
long ms (i.e. currentinmlilies)?我在Google上寻找它,但我只能找到如何将ms转换为日期.
注意:为了说清楚,我想从1970/1/1格式的日期获得ms.
我现在创建日期:
ZoneId gmt = ZoneId.of("GMT");
LocalDateTime localDateTime = LocalDateTime.now();
LocalDate localDateNow = localDateTime.toLocalDate();
Run Code Online (Sandbox Code Playgroud)
然后我希望以毫秒为单位返回此日期:
localDateNow.atStartOfDay(gmt) - 22.08.2017
localDateNow.atStartOfDay(gmt).toEpochSecond(); - 1503360000 (18.01.70)
Run Code Online (Sandbox Code Playgroud)
我怎么能LocalDate.now()在几毫秒内返回?
我的时间有问题
我的服务器在美国,我在丹麦(Europa),我想让我的网站显示当地时间.我怎样才能做到这一点?
我试试这个
Datetime localtime = DateTimeOffset.Now.ToOffset(new TimeSpan(1,0,0)).DateTime;
Run Code Online (Sandbox Code Playgroud)
并且它有效,但它只能在我使用GMT + 1/UTC + 1时工作,而不是在我使用GMT + 2/UTC + 2时工作.有没有另一种方法 - 这是一种更简单的方法吗?