简体   繁体   English

如何在Java中初始化Instant

[英]How can I initialize Instant in Java

How can I initialize an instant type? 如何初始化即时类型?

I tried this: 我尝试了这个:

Instant instant = new Instant();

But doesn't work.. 但不起作用..

I need it because after on Freemarker I have to do this: 我需要它,因为在Freemarker上之后,我必须这样做:

[#assign dateFormated = newDate.from(instant.ofEpochSecond(data.time.seconds))/]

Straight from the Oracle tutorial : 直接来自Oracle 教程

import java.time.Instant;

Instant timestamp = Instant.now()

You will find other explanations there as well. 您也可以在此处找到其他说明。

Thus the real answer is: by doing some research. 因此,真正的答案是:通过做一些研究。 Especially the standard library classes come with extensive amounts of Javadoc explaining all of their aspects and most often, there are plenty of tutorials out there, too. 尤其是标准库类附带了大量Javadoc,解释了它们的所有方面, 并且最常见的是,那里也有很多教程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM