Java OffsetDateTime getCurrentISODate()

Here you can find the source of getCurrentISODate()

Description

get Current ISO Date

License

Open Source License

Declaration

public static String getCurrentISODate() 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.time.Instant;

import java.time.OffsetDateTime;
import java.time.ZoneId;

import java.time.format.DateTimeFormatter;

public class Main {
    /** ISO DATE format. It's used in ePub generator. */
    private static final DateTimeFormatter ISO_DATE = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ");

    public static String getCurrentISODate() {
        return ms2OffsetDateTime(System.currentTimeMillis()).format(ISO_DATE);
    }//from  w w  w  .  j a  va2s .  c  o  m

    /**
     * ms -> OffsetDateTime object.
     * @param ms millisecond
     * @return LocalDateTime
     */
    public static OffsetDateTime ms2OffsetDateTime(final long ms) {
        return OffsetDateTime.ofInstant(Instant.ofEpochMilli(ms), ZoneId.systemDefault());
    }
}

Related

  1. asDate(Calendar calendar)
  2. cloneInternally(E source, Map visited)
  3. compareChrono(TemporalAccessor date1, TemporalAccessor date2)
  4. compareOffsetDateTimes(OffsetDateTime offsetDateTime1, OffsetDateTime offsetDateTime2)
  5. convertDateToOffsetDateTime(Date date)
  6. getDateTimeString(OffsetDateTime time)
  7. getNowOdt()
  8. hasZone(TemporalAccessor date)
  9. next(OffsetDateTime date, OffsetTime time)