Java Utililty Methods SQL LocalDate

List of utility methods to do SQL LocalDate

Description

The list of methods to do SQL LocalDate are organized into topic(s).

Method

Dateadd(Date awal, int i)
add
LocalDate localDate = awal.toLocalDate();
LocalDate newDate = localDate.plusDays(i);
return toDate(newDate);
DateaddDays(final Date date, final int daysToAdd)
add Days
return new Date(Date.valueOf(date.toLocalDate().plusDays(daysToAdd)).getTime());
LocalDateasLocalDate(Date date)
as Local Date
if (date == null) {
    return null;
if (date instanceof java.sql.Date) {
    return ((java.sql.Date) date).toLocalDate();
} else {
    return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDate();
LocalDateasLocalDate(Date date)
Obtains an instance of LocalDate from a date object.
return asLocalDate(date, getDefaultTimeZone());
LocalDateasLocalDate(java.util.Date date, ZoneId zone)
as Local Date
if (date == null)
    return null;
if (date instanceof java.sql.Date)
    return ((java.sql.Date) date).toLocalDate();
else
    return Instant.ofEpochMilli(date.getTime()).atZone(zone).toLocalDate();
DateasUtilDate(Object date)
Calls #asUtilDate(Object,ZoneId) with the system default time zone.
return asUtilDate(date, ZoneId.systemDefault());
java.util.DateasUtilDate(Object date, ZoneId zone)
Creates a java.util.Date from various date objects.
if (date == null) {
    return null;
if (date instanceof java.sql.Date || date instanceof java.sql.Timestamp) {
    return new java.util.Date(((java.util.Date) date).getTime());
if (date instanceof java.util.Date) {
    return (java.util.Date) date;
...
DateconvertLocalDateToDatabaseDate(LocalDate localDate)
convert Local Date To Database Date
return Date.valueOf(localDate);
intgetDay(Date date)
get Day
LocalDate localDate = date.toLocalDate();
return localDate.getDayOfMonth();
DategetLastDate()
get Last Date
LocalDate localDate = LocalDate.now();
Date date = Date.valueOf(localDate);
int year = getYear(date);
Month month = getMonth(date);
return getLastDate(month, year);