List of utility methods to do LocalDate Calculate
LocalDate | converterToLocalDate(final String date) converter To Local Date return LocalDate.parse(date);
|
String | convertLocalDateToDatabaseDateString(LocalDate localDate) convert Local Date To Database Date String DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); return localDate.format(formatter); |
LocalDate | dateToSystemLocalDate(Date d) Takes a java.util.Date and turns it into a LocalDate based on the systems default timezone. return d.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
int | daysAgo(LocalDate pastDate) days Ago return 0;
|
int | doy(LocalDate date) Finds the day-of-year of the date. int[] lookup = (date.isLeapYear() ? LEAP : STANDARD); return lookup[date.getMonthValue()] + date.getDayOfMonth(); |
char[] | fastDateWrite(LocalDate localDate) fast Date Write char[] c = new char[10]; int y = localDate.getYear(); c[0] = (char) ('0' + y / 1000); c[1] = (char) ('0' + ((y % 1000) / 100)); c[2] = (char) ('0' + ((y % 100) / 10)); c[3] = (char) ('0' + (y % 10)); c[4] = (char) ('-'); int m = localDate.getMonthValue(); ... |
char[] | fastDateWriteWeeks(LocalDate localDate) fast Date Write Weeks char[] c = new char[7]; int y = localDate.get(yearOfWeek); c[0] = (char) ('0' + y / 1000); c[1] = (char) ('0' + ((y % 1000) / 100)); c[2] = (char) ('0' + ((y % 100) / 10)); c[3] = (char) ('0' + (y % 10)); c[4] = (char) ('W'); int w = localDate.get(weekOfYear); ... |
int | getAge(LocalDate birthday) get Age LocalDate now = LocalDate.now(); int age = now.getYear() - birthday.getYear(); if (age <= 0) { return 0; int currentMonth = now.getMonthValue(); int currentDay = now.getDayOfMonth(); int bornMonth = birthday.getMonthValue(); ... |
int | getAge(LocalDate birthDay) get Age return LocalDate.now().getYear() - birthDay.getYear();
|
Date | getDate(ChronoLocalDate date) get Date LocalDate localDate = LocalDate.from(date);
ZoneId zone = ZoneId.systemDefault();
Instant instant = localDate.atStartOfDay().atZone(zone).toInstant();
return Date.from(instant);
|