DateUtils { public static String convertToReadableTime(Long timestamp) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return dateFormat.format(new Date(timestamp)); }  static String convertToReadableTime(Long timestamp); static Long convertToTimestamp(String time, String format); static Date convertToDate(String date); static String convertDateToString(Date date); static Long getDateDifferenceInMinutes(Date oldTime); static boolean isFutureTime(Date time); static Date getDateSpecifiedTimeAgo(String periodString); static final String ALLOWED_DATE_FORMAT; }
@Test public void testConvertToReadableTime() throws Exception { Long timestamp = 1389125737000L; String readableTime = DateUtils.convertToReadableTime(timestamp); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); Assert.assertEquals("2014-01-07 20:15:37", sdf.format(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(readableTime))); }