Example usage for java.time Instant parse

List of usage examples for java.time Instant parse

Introduction

In this page you can find the example usage for java.time Instant parse.

Prototype

public static Instant parse(final CharSequence text) 

Source Link

Document

Obtains an instance of Instant from a text string such as 2007-12-03T10:15:30.00Z .

Usage

From source file:Main.java

public static void main(String[] args) {
    Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");
    instant = instant.with(ChronoField.MILLI_OF_SECOND, 20);
    System.out.println(instant);/*from  w  ww.  java  2  s  .c o m*/

}

From source file:Main.java

public static void main(String[] args) {

    // parsing from ISO 8601
    Instant fromIso8601 = Instant.parse("2010-01-01T12:00:00Z");

    System.out.println(fromIso8601);
}

From source file:Main.java

public static void main(String[] args) {
    Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");
    ZonedDateTime l = ZonedDateTime.now();
    System.out.println(instant.until(l, ChronoUnit.DAYS));

}

From source file:Main.java

public static void main(String[] args) {
    Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");
    ZonedDateTime l = ZonedDateTime.now();
    Temporal t = instant.adjustInto(l);
    System.out.println((ZonedDateTime) t);

}

From source file:Main.java

public static void main(String[] args) {
    Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");

    LocalDate z = instant.query(TemporalQueries.localDate());
    System.out.println(z);//www.  j av  a2  s.c om

}

From source file:Main.java

public static void main(String[] args) {
    Instant instant = Instant.parse("2014-07-16T10:15:30.00Z");
    LocalDate localDate = LocalDate.parse("2014-07-16", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
    LocalDate localDate2 = LocalDate.parse("2014-07-16", DateTimeFormatter.ISO_LOCAL_DATE);

    DateTimeFormatter strangeFormat = new DateTimeFormatterBuilder().appendValue(MONTH_OF_YEAR, 2)
            .appendLiteral("==").appendValue(YEAR, 4).appendLiteral("--").appendValue(DAY_OF_MONTH, 2)
            .toFormatter();//from www  .j  a va  2s . co  m

    LocalDate localDate3 = LocalDate.parse("07==2014--16", strangeFormat);

    System.out.println(instant);
    System.out.println(localDate);
    System.out.println(localDate2);
    System.out.println(localDate3);

    LocalDate date = Year.of(2014).atMonth(7).atDay(16);
    String strangeDateFormat = date.format(strangeFormat);

    System.out.println(strangeDateFormat);
}

From source file:net.javacrumbs.codecamp.common.CsvFileLogger.java

private static Message parseRecord(CSVRecord record) {
    return new Message(Message.Severity.valueOf(record.get(0)), record.get(1), Instant.parse(record.get(2)));
}

From source file:com.hp.autonomy.hod.client.api.resource.ResourceDetails.java

public ResourceDetails(@JsonProperty("resource") final Resource resource,
        @JsonProperty("description") final String description, @JsonProperty("type") final ResourceType type,
        @JsonProperty("date_created") final String dateCreated,
        @JsonProperty("display_name") final String displayName) {
    this.resource = resource;
    this.description = description;
    this.type = type;
    this.displayName = displayName;

    this.dateCreated = dateCreated != null ? Instant.parse(dateCreated) : null;
}

From source file:org.travis4j.model.json.AbstractJsonObject.java

public Instant getInstant(String key) {
    return (json.isNull(key)) ? null : Instant.parse(json.getString(key));
}

From source file:info.losd.galen.json.StringToInstantDeserializer.java

@Override
public Instant deserialize(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    return Instant.parse(jp.getText());
}