Answers for "UTC time java"

1

java get date in utc

OffsetDateTime now = OffsetDateTime.now(ZoneOffset.UTC);
System.out.println(now);
Posted by: Guest on July-08-2020
0

java get date in utc

private static Date getCurrentUtcTime() throws ParseException {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss");
    simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    SimpleDateFormat localDateFormat = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss");
    return localDateFormat.parse( simpleDateFormat.format(new Date()) );
}
Posted by: Guest on July-08-2020
0

UTC in Java

import java.time.Instant;

Instant timestamp = Instant.now()	// gives the UTC time
Posted by: Guest on September-16-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language