@Test public void testGetDate() { Date date = DateUtils.getDate(1, 2, 3); Calendar cal = Calendar.getInstance(); cal.setTime(date); assertEquals(1, cal.get(Calendar.YEAR)); assertEquals(2, cal.get(Calendar.MONTH)); assertEquals(3, cal.get(Calendar.DAY_OF_MONTH)); assertEquals(0, cal.get(Calendar.HOUR_OF_DAY)); assertEquals(0, cal.get(Calendar.MINUTE)); assertEquals(0, cal.get(Calendar.SECOND)); assertEquals(0, cal.get(Calendar.MILLISECOND)); }
public static Date getDate(int year, int month, int day) { Calendar calendar = Calendar.getInstance(); if (year>0) calendar.set(Calendar.YEAR, year); if (month>=0) calendar.set(Calendar.MONTH, month); if (day>0) calendar.set(Calendar.DAY_OF_MONTH, day); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar.getTime(); }
DateUtils { public static Date getDate(int year, int month, int day) { Calendar calendar = Calendar.getInstance(); if (year>0) calendar.set(Calendar.YEAR, year); if (month>=0) calendar.set(Calendar.MONTH, month); if (day>0) calendar.set(Calendar.DAY_OF_MONTH, day); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar.getTime(); } }
DateUtils { public static Date getDate(int year, int month, int day) { Calendar calendar = Calendar.getInstance(); if (year>0) calendar.set(Calendar.YEAR, year); if (month>=0) calendar.set(Calendar.MONTH, month); if (day>0) calendar.set(Calendar.DAY_OF_MONTH, day); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar.getTime(); } private  DateUtils(); }
DateUtils { public static Date getDate(int year, int month, int day) { Calendar calendar = Calendar.getInstance(); if (year>0) calendar.set(Calendar.YEAR, year); if (month>=0) calendar.set(Calendar.MONTH, month); if (day>0) calendar.set(Calendar.DAY_OF_MONTH, day); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar.getTime(); } private  DateUtils(); static Date getDateNow(); static Date getTimeNow(); static Date addDate(Date date, int years, int months, int days); static Date setDate(Date date, int year, int month, int day); static Date getDate(int year, int month, int day); static Date setTime(Date date, int hours, int minutes, int seconds, int millis); static Date getDateOnly(Date date); static Date parseDate(String sDate, Locale locale); static String formatDate(Date d, Locale locale); static String formatTime(Date d, Locale locale, boolean withSeconds); static String formatDayOfWeek(Date d, Locale locale, boolean longFormat); static String formatMonth(Date d, Locale locale, boolean longFormat); static int getWeekOfYear(Date d, Locale locale); static String formatMonth(int month, Locale locale, boolean longFormat); static String formatYear(Date d, Locale locale); }
DateUtils { public static Date getDate(int year, int month, int day) { Calendar calendar = Calendar.getInstance(); if (year>0) calendar.set(Calendar.YEAR, year); if (month>=0) calendar.set(Calendar.MONTH, month); if (day>0) calendar.set(Calendar.DAY_OF_MONTH, day); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar.getTime(); } private  DateUtils(); static Date getDateNow(); static Date getTimeNow(); static Date addDate(Date date, int years, int months, int days); static Date setDate(Date date, int year, int month, int day); static Date getDate(int year, int month, int day); static Date setTime(Date date, int hours, int minutes, int seconds, int millis); static Date getDateOnly(Date date); static Date parseDate(String sDate, Locale locale); static String formatDate(Date d, Locale locale); static String formatTime(Date d, Locale locale, boolean withSeconds); static String formatDayOfWeek(Date d, Locale locale, boolean longFormat); static String formatMonth(Date d, Locale locale, boolean longFormat); static int getWeekOfYear(Date d, Locale locale); static String formatMonth(int month, Locale locale, boolean longFormat); static String formatYear(Date d, Locale locale);  }