Java LocalDateTime Create localDateTime(Date date, Clock clock)

Here you can find the source of localDateTime(Date date, Clock clock)

Description

local Date Time

License

Open Source License

Return

passed in date converted to local date time using the provided clock

Declaration

public static LocalDateTime localDateTime(Date date, Clock clock) 

Method Source Code


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

import java.time.Clock;

import java.time.LocalDateTime;

import java.util.Date;

public class Main {
    private static final Clock DEFAULT_CLOCK = Clock.systemUTC();

    /**// w w w .  ja  v a 2  s . c  o  m
     * @return passed in date converted to local date time using the provided clock
     */
    public static LocalDateTime localDateTime(Date date, Clock clock) {
        return LocalDateTime.ofInstant(date.toInstant(), clock.getZone());
    }

    /**
     * @return passed in date converted to local date time using the default clock
     */
    public static LocalDateTime localDateTime(Date date) {
        return localDateTime(date, DEFAULT_CLOCK);
    }
}

Related

  1. asLocalDateTime(Date date)
  2. getLocalDateTime(Date datetime, TimeZone timeZone)
  3. getLocalDateTimeFromEpochMilli(long epochMillis)
  4. getLocalDateTimeFromMillis(final long millis)
  5. getLocalDateTimeFromMillis(long millis)
  6. localDateTimeOf(final String value)
  7. toLocalDateTime(java.util.Date d)
  8. toLocalDateTime(long systemMillis)