Java LocalDate Create getLocalDate(java.util.Date date)

Here you can find the source of getLocalDate(java.util.Date date)

Description

Convert a Date to a LocalDate at the system's default time zone.

License

BSD License

Declaration

public static LocalDate getLocalDate(java.util.Date date) 

Method Source Code

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

import java.time.*;

public class Main {
    /**//from  ww  w  .  ja  va 2 s  .c o  m
     * Convert a Date to a LocalDate at the system's default time zone. Returns null on null input.
     */
    public static LocalDate getLocalDate(java.util.Date date) {
        if (date == null)
            return null;
        return getLocalDateTime(date).toLocalDate();
    }

    /**
     * Convert a Date to a LocalDateTime at the system's default time zone. Returns null on null input.
     */
    public static LocalDateTime getLocalDateTime(java.util.Date date) {
        if (date == null)
            return null;
        return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
    }
}

Related

  1. getCurrentLocalDate()
  2. getCurrentLocalDate()
  3. getCurrentLocalDate()
  4. getLocalDate(int year, int atDay)
  5. getLocalDate(long timeInMillis)
  6. toLocalDate(Calendar calendar)
  7. toLocalDate(final Date date)