Java ZonedDateTime Calculate toLocalDateString(ZonedDateTime zonedDateTime)

Here you can find the source of toLocalDateString(ZonedDateTime zonedDateTime)

Description

Converts a LocalDateTime to a UTC ISO_8601 string representation

e.g.

License

Open Source License

Parameter

Parameter Description
zonedDateTime a parameter

Return

UTC ISO_8601 date string

Declaration

public static String toLocalDateString(ZonedDateTime zonedDateTime) 

Method Source Code


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

import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

public class Main {
    private static final ZoneId UTC = ZoneId.of("Z");
    private static DateTimeFormatter localDateFormatter = DateTimeFormatter.ISO_LOCAL_DATE;

    /**//from  w  ww .  ja v a2 s.co m
     * Converts a LocalDateTime to a UTC ISO_8601 string representation
     * <p>
     * e.g. <br/>
     * 1. LocalDateTime("2010-01-01") ==> "2010-12-01" <br/>
     * 2. LocalDateTime("2010-12-31") ==> "2010-12-31" <br/>
     * </p>
     *
     * @param zonedDateTime
     * @return UTC ISO_8601 date string
     */
    public static String toLocalDateString(ZonedDateTime zonedDateTime) {
        return zonedDateTime.withZoneSameInstant(ZoneOffset.UTC).toLocalDate().format(localDateFormatter);
    }
}

Related

  1. simplifyZonedDateTime(ZonedDateTime now, long timeToWait)
  2. stringToZonedDateTimeUTC(String dateAsString)
  3. timestampToZonedDateTime(Long timestamp)
  4. toEpochMillSeconds(ZonedDateTime time)
  5. toEpochTime(ZonedDateTime input)
  6. toUTCZonedDateTime(String dateString)
  7. toZeroMSN(ZonedDateTime dateTime)
  8. uaDateTimeFromTime(ZonedDateTime time)
  9. Youngest(ZonedDateTime ZDT1, ZonedDateTime ZDT2)