Timestamp date = DateUtil.parseYYYYMM("2020-06"); LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); //The last day of the month LocalDate lastDay =localDate.with(TemporalAdjusters.lastDayOfMonth()); System.out.println("-------------------"+localDate.getYear()+"-"+localDate.getMonth().getValue()+"-"+lastDay.getDayOfMonth());
Output result:
-------------------2020-6-30