Java ZonedDateTime Create zonedDateTimeOf(final ZonedDateTime time)

Here you can find the source of zonedDateTimeOf(final ZonedDateTime time)

Description

Utility for creating a ZonedDateTime object from a ZonedDateTime.

License

Apache License

Parameter

Parameter Description
time ZonedDateTime to be copied

Return

ZonedDateTime representing time

Declaration

@Deprecated
public static ZonedDateTime zonedDateTimeOf(final ZonedDateTime time) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import org.joda.time.ReadableInstant;

import java.time.Instant;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.Calendar;
import java.util.Date;

public class Main {
    /**/* www  . j a  v  a 2s .c  om*/
     * Utility for creating a ZonedDateTime object from a ZonedDateTime.
     * @param time ZonedDateTime to be copied
     * @return ZonedDateTime representing time
     * @deprecated Java 8 transition utility method
     */
    @Deprecated
    public static ZonedDateTime zonedDateTimeOf(final ZonedDateTime time) {
        return ZonedDateTime.from(time);
    }

    /**
     * Utility for creating a ZonedDateTime object from a millisecond timestamp.
     * @param time Miliseconds since Epoch UTC
     * @return ZonedDateTime representing time
     */
    public static ZonedDateTime zonedDateTimeOf(final long time) {
        return zonedDateTimeOf(time, ZoneOffset.UTC);
    }

    /**
     * Utility for creating a ZonedDateTime object from a millisecond timestamp.
     * @param time Miliseconds since Epoch
     * @param zoneId Time zone
     * @return ZonedDateTime representing time
     */
    public static ZonedDateTime zonedDateTimeOf(final long time, final ZoneId zoneId) {
        return ZonedDateTime.ofInstant(Instant.ofEpochMilli(time), zoneId);
    }

    /**
     * Gets ZonedDateTime for ReadableInstant.
     * @param time Time object to be converted.
     * @return ZonedDateTime representing time
     * @deprecated Java 8 transition utility method
     */
    @Deprecated
    public static ZonedDateTime zonedDateTimeOf(final ReadableInstant time) {
        return zonedDateTimeOf(time.getMillis());
    }

    /**
     * Gets ZonedDateTime for Date.
     * @param time Time object to be converted.
     * @return ZonedDateTime representing time
     * @deprecated Java 8 transition utility method
     */
    @Deprecated
    public static ZonedDateTime zonedDateTimeOf(final Date time) {
        return zonedDateTimeOf(time.getTime());
    }

    /**
     * Gets ZonedDateTime for Calendar.
     * @param time Time object to be converted.
     * @return ZonedDateTime representing time
     * @deprecated Java 8 transition utility method
     */
    @Deprecated
    public static ZonedDateTime zonedDateTimeOf(final Calendar time) {
        return ZonedDateTime.ofInstant(time.toInstant(), time.getTimeZone().toZoneId());
    }
}

Related

  1. toZonedDateTime(Date utilDate)
  2. toZonedDateTime(long epochSeconds)
  3. toZonedDateTime(long systemMillis)
  4. toZonedDateTime(Object cell)
  5. zonedDateTime(String date, ZoneId zoneId)
  6. zonedDateTimeToYyyyMMdd(LocalDate localDate)