[Java] Calendar related

less than 1 minute read

Calendar c = Calendar.getInstance();
c.add(Calendar.YEAR, -1);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);

c.getTime();

Date.from(LocalDate.now().minusYear(1L).atStartOfDay(ZoneId.systemDefault().toInstant());

Tags:

Updated: