Java SQL LocalDate asLocalDate(Date date)

Here you can find the source of asLocalDate(Date date)

Description

as Local Date

License

Open Source License

Declaration

public static LocalDate asLocalDate(Date date) 

Method Source Code


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

import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;

public class Main {
    public static LocalDate asLocalDate(Date date) {

        if (date == null) {
            return null;
        }/*from   w w  w.jav a2 s  .c o  m*/

        if (date instanceof java.sql.Date) {
            return ((java.sql.Date) date).toLocalDate();
        } else {
            return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDate();
        }
    }
}

Related

  1. add(Date awal, int i)
  2. addDays(final Date date, final int daysToAdd)
  3. asLocalDate(Date date)
  4. asLocalDate(java.util.Date date, ZoneId zone)
  5. asUtilDate(Object date)
  6. asUtilDate(Object date, ZoneId zone)
  7. convertLocalDateToDatabaseDate(LocalDate localDate)