DateUtils { public static Date toDate(String strDate) throws ParseException { SimpleDateFormat fullDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); return fullDateFormat.parse(strDate); }  static long getCollectTimeInLong(Date date); static Date convertToServerDate(String userTimeZone, Date userDate); static Date convertToUserDate(String userTimeZone, Date serverDate); static String dateToString(Date date); static Map<String, String> getFilteredTimeZoneMap(); static Date toSimpleDate(String strDate); static Date toDate(String strDate); static Date addDay(Date date, int days); static String ms2Time(long ms); static long timeToMs(int day, int hour, int min, int sec); static boolean compareDateEndWithMinute(Date d1, Date d2);  }
@Test public void testToDate() throws ParseException { String dateStr = DateUtils.dateToString(new Date()); Date newDate = DateUtils.toDate(dateStr); assertThat(newDate, notNullValue()); }