Example usage for java.time.format DateTimeFormatter ISO_DATE_TIME

List of usage examples for java.time.format DateTimeFormatter ISO_DATE_TIME

Introduction

In this page you can find the example usage for java.time.format DateTimeFormatter ISO_DATE_TIME.

Prototype

DateTimeFormatter ISO_DATE_TIME

To view the source code for java.time.format DateTimeFormatter ISO_DATE_TIME.

Click Source Link

Document

The ISO-like date-time formatter that formats or parses a date-time with the offset and zone if available, such as '2011-12-03T10:15:30', '2011-12-03T10:15:30+01:00' or '2011-12-03T10:15:30+01:00[Europe/Paris]'.

Usage

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.parse("2014-06-30T12:01:00", DateTimeFormatter.ISO_DATE_TIME);

    System.out.println(a);//  w  ww  . ja  v  a2s. c om
}

From source file:Main.java

public static void main(String[] args) {
    OffsetDateTime o = OffsetDateTime.now();
    String l = o.format(DateTimeFormatter.ISO_DATE_TIME);
    System.out.println(l);/*from   w w w .  j  av  a  2 s  .com*/
}

From source file:Main.java

public static void main(String[] args) {
    OffsetDateTime o = OffsetDateTime.parse("2014-09-02T15:22:14.59-07:00", DateTimeFormatter.ISO_DATE_TIME);

    System.out.println(o);//from w w w. j  a  v a2  s  .com
}

From source file:Main.java

public static void main(String[] args) {
    ZonedDateTime dateTime = ZonedDateTime.from(ZonedDateTime.now());
    String s = dateTime.format(DateTimeFormatter.ISO_DATE_TIME);
    System.out.println(s);/*w w  w .j a v  a  2s .  co m*/
}

From source file:Main.java

public static void main(String[] args) {
    ZonedDateTime dateTime = ZonedDateTime.parse("2014-09-03T11:38:45.902-07:00[America/Los_Angeles]",
            DateTimeFormatter.ISO_DATE_TIME);

    System.out.println(dateTime);
}

From source file:Main.java

public static void main(String[] args) {
    // 2014-04-01 10:45
    LocalDateTime dateTime = LocalDateTime.of(2014, Month.APRIL, 1, 10, 45);

    // format ISO date time (2014-02-20T20:04:05.867)
    String asIsoDateTime = dateTime.format(DateTimeFormatter.ISO_DATE_TIME);

    System.out.println(asIsoDateTime);
}

From source file:com.devcraftsman.blog.post.api.util.ISOLocalDateTimeDeserializer.java

@Override
public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    if (p.getText() != null)
        return LocalDateTime.parse(p.getText(), DateTimeFormatter.ISO_DATE_TIME);
    else//from  ww w . j av  a  2  s.c o  m
        return null;
}

From source file:com.devcraftsman.blog.post.api.util.ISOLocalDateTimeSerializer.java

@Override
public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider serializers)
        throws IOException {
    if (value != null) {
        gen.writeString(value.format(DateTimeFormatter.ISO_DATE_TIME));
    }/*from  w w w  .  ja  v a  2 s  .  c o  m*/

}

From source file:edu.psu.swe.scim.spec.protocol.filter.AttributeComparisonExpression.java

public static String toDateTimeString(LocalDateTime ldt) {
    return ldt.format(DateTimeFormatter.ISO_DATE_TIME);
}

From source file:eu.hansolo.tilesfx.weather.Sun.java

private static ZonedDateTime[] parseJsonData(final String JSON_DATA, final ZoneId ZONE_ID) {
    Object obj = JSONValue.parse(JSON_DATA);
    JSONObject jsonObj = (JSONObject) obj;

    // Results/*  w w  w.  ja v  a 2s  .com*/
    JSONObject results = (JSONObject) jsonObj.get("results");

    LocalDateTime sunrise = LocalDateTime.parse(results.get("sunrise").toString(),
            DateTimeFormatter.ISO_DATE_TIME);
    LocalDateTime sunset = LocalDateTime.parse(results.get("sunset").toString(),
            DateTimeFormatter.ISO_DATE_TIME);
    /*
    LocalDateTime solarNoon                 = LocalDateTime.parse(results.get("solar_noon").toString(), DateTimeFormatter.ISO_DATE_TIME);
    LocalDateTime dayLength                 = LocalDateTime.parse(results.get("day_length").toString(), DateTimeFormatter.ISO_DATE_TIME);
    LocalDateTime civilTwilightBegin        = LocalDateTime.parse(results.get("civil_twilight_begin").toString(), DateTimeFormatter.ISO_DATE_TIME);
    LocalDateTime nauticalTwilightBegin     = LocalDateTime.parse(results.get("nautical_twilight_begin").toString(), DateTimeFormatter.ISO_DATE_TIME);
    LocalDateTime nauticalTwilightEnd       = LocalDateTime.parse(results.get("nautical_twilight_end").toString(), DateTimeFormatter.ISO_DATE_TIME);
    LocalDateTime astronomicalTwilightBegin = LocalDateTime.parse(results.get("astronomical_twilight_begin").toString(), DateTimeFormatter.ISO_DATE_TIME);
    LocalDateTime astronomicalTwilightEnd   = LocalDateTime.parse(results.get("astronomical_twilight_end").toString(), DateTimeFormatter.ISO_DATE_TIME);
    */

    return new ZonedDateTime[] { ZonedDateTime.of(sunrise, ZONE_ID), ZonedDateTime.of(sunset, ZONE_ID) };
}