In Java 8 Instant.now()
method showing wrong time .
My code looks like :
import java.time.*;
import java.time.temporal.*;
public class DateTimeDemo{
public static void main(String []args){
Instant now = Instant.now();
System.out.println(now);
}
}
Its date part is correct but time part .
eg
2016-07-11T11:01:25.498Z but in my system it is 4.31 PM
I am using Asia/Calcutta TimeZone
That's the correct time. Note the "Z" at the end, indicating UTC - 11:01:25 in UTC is 16:31:25 in Asia/Calcutta.
If you want to represent "now" in your default time zone, use ZonedDateTime.now()
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With