@Test public void testJoinDateAndTime() { Date date = DateUtil.newDate(2008, Calendar.JULY, 3); Date time = DateUtil.newDate(1970, Calendar.JANUARY, 1, 22, 56, 32); Date expected = DateUtil.newDate(2008, Calendar.JULY, 3, 22, 56, 32); Date joined = DateUtil.joinDateAndTime(date, time); assertEquals(expected, joined); }
public static Date joinDateAndTime(final Date date, final Date time) { Calendar dateCal = Calendar.getInstance(); dateCal.setTime(date); Calendar timeCal = Calendar.getInstance(); timeCal.setTime(time); dateCal.set(Calendar.HOUR_OF_DAY, timeCal.get(Calendar.HOUR_OF_DAY)); dateCal.set(Calendar.MINUTE, timeCal.get(Calendar.MINUTE)); dateCal.set(Calendar.SECOND, timeCal.get(Calendar.SECOND)); dateCal.set(Calendar.MILLISECOND, timeCal.get(Calendar.MILLISECOND)); return dateCal.getTime(); }
DateUtil { public static Date joinDateAndTime(final Date date, final Date time) { Calendar dateCal = Calendar.getInstance(); dateCal.setTime(date); Calendar timeCal = Calendar.getInstance(); timeCal.setTime(time); dateCal.set(Calendar.HOUR_OF_DAY, timeCal.get(Calendar.HOUR_OF_DAY)); dateCal.set(Calendar.MINUTE, timeCal.get(Calendar.MINUTE)); dateCal.set(Calendar.SECOND, timeCal.get(Calendar.SECOND)); dateCal.set(Calendar.MILLISECOND, timeCal.get(Calendar.MILLISECOND)); return dateCal.getTime(); } }
DateUtil { public static Date joinDateAndTime(final Date date, final Date time) { Calendar dateCal = Calendar.getInstance(); dateCal.setTime(date); Calendar timeCal = Calendar.getInstance(); timeCal.setTime(time); dateCal.set(Calendar.HOUR_OF_DAY, timeCal.get(Calendar.HOUR_OF_DAY)); dateCal.set(Calendar.MINUTE, timeCal.get(Calendar.MINUTE)); dateCal.set(Calendar.SECOND, timeCal.get(Calendar.SECOND)); dateCal.set(Calendar.MILLISECOND, timeCal.get(Calendar.MILLISECOND)); return dateCal.getTime(); } private  DateUtil(); }
DateUtil { public static Date joinDateAndTime(final Date date, final Date time) { Calendar dateCal = Calendar.getInstance(); dateCal.setTime(date); Calendar timeCal = Calendar.getInstance(); timeCal.setTime(time); dateCal.set(Calendar.HOUR_OF_DAY, timeCal.get(Calendar.HOUR_OF_DAY)); dateCal.set(Calendar.MINUTE, timeCal.get(Calendar.MINUTE)); dateCal.set(Calendar.SECOND, timeCal.get(Calendar.SECOND)); dateCal.set(Calendar.MILLISECOND, timeCal.get(Calendar.MILLISECOND)); return dateCal.getTime(); } private  DateUtil(); static Date joinDateAndTime(final Date date, final Date time); static Date newDate(final int year, final int month, final int date); static Date newDate(final int year,
                               final int month,
                               final int date,
                               final int hourOfDay,
                               final int minute,
                               final int second); static Date stripDate(final Date date); static Date stripTime(final Date date); }
DateUtil { public static Date joinDateAndTime(final Date date, final Date time) { Calendar dateCal = Calendar.getInstance(); dateCal.setTime(date); Calendar timeCal = Calendar.getInstance(); timeCal.setTime(time); dateCal.set(Calendar.HOUR_OF_DAY, timeCal.get(Calendar.HOUR_OF_DAY)); dateCal.set(Calendar.MINUTE, timeCal.get(Calendar.MINUTE)); dateCal.set(Calendar.SECOND, timeCal.get(Calendar.SECOND)); dateCal.set(Calendar.MILLISECOND, timeCal.get(Calendar.MILLISECOND)); return dateCal.getTime(); } private  DateUtil(); static Date joinDateAndTime(final Date date, final Date time); static Date newDate(final int year, final int month, final int date); static Date newDate(final int year,
                               final int month,
                               final int date,
                               final int hourOfDay,
                               final int minute,
                               final int second); static Date stripDate(final Date date); static Date stripTime(final Date date);  }