Answers for "How to get UTC+0 date in Java 8"

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

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language