示例#1
0
  private static Date getDate(int year, int month, int day) {
    if (year < 0 || month < 0 || day < 0)
      throw new IllegalArgumentException("Values must be greater of 0");

    final Calendar c = Calendar.getInstance();
    c.set(year, month, day);

    return DateUtils.setTimeToBeginningOfDay(c).getTime();
  }
示例#2
0
 /**
  * Test method for {@link it.reexon.lib.date.DateUtils#setTimeToBeginningOfDay(java.util.Date)}.
  */
 @Test
 public final void testSetTimeToBeginningOfDayDate() {
   try {
     Date timeToEndOfDay = DateUtils.setTimeToBeginningOfDay(date01);
     Calendar cal = new Calendar.Builder().setInstant(timeToEndOfDay).build();
     cal.set(Calendar.HOUR_OF_DAY, 00);
     cal.set(Calendar.SECOND, 00);
     cal.set(Calendar.MILLISECOND, 000);
     Assert.assertEquals(cal.getTimeInMillis(), timeToEndOfDay.getTime());
   } catch (Exception e) {
     logger.error(e.getMessage(), e);
     throw new RuntimeException(e);
   }
 }