TimeUtils { public static Date endMonth(int year, int month) { return new Date(new DateTime(beginMonth(year, month)).plusMonths(1).toDate().getTime() - 1); } private  TimeUtils(); static String nowStr(); static String date2Str(Date date); static String date2Str(long date); static int month(); static Date yesterdayBegin(); static Date yesterdayEnd(); static Date pastWeekStart(); static Long howLongBeginThisMonth(); static Date beginThisMonth(); static Date lastMonthTodayInBegin(); static Date lastFewDaysInBegin(Integer days); static Date fewDaysAgoEnd(int index); static Date fewDaysAgoBegin(int index); static Date endMonth(int year, int month); static Date beginMonth(int year, int month); static Date zeroTimeZone(Date date); static String nowTimeWithZone();  }
@Test public void endMonthTester() { assertEquals("2016-07-31 23:59:59:999", sdf.format(TimeUtils.endMonth(2016, 7))); }