List of utility methods to do Time Format
String | getFormatDatetime() get Format Datetime GregorianCalendar gCalendar = new GregorianCalendar(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String strDateTime; try { strDateTime = formatter.format(gCalendar.getTime()); } catch (Exception ex) { System.out.println("Error Message:".concat(String.valueOf(String.valueOf(ex.toString())))); String s = null; ... |
String | getFormatDateTime(Date date) get Format Date Time return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date); |
String | getFormatDateTime(Date date, String format) get Format Date Time SimpleDateFormat sdf; if (format == null || format.equalsIgnoreCase("")) { sdf = new SimpleDateFormat(DEFAULT_FORMAT); } else { sdf = new SimpleDateFormat(format); return sdf.format(date); |
String | getFormatDateTime(java.util.Date date) get Format Date Time return format(date, "yyyyMMddHHmmss"); |
String | getFormattedCurrentDateAndTime() get Formatted Current Date And Time SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = new Date(System.currentTimeMillis()); return formatter.format(date); |
String | getFormattedCurrentDateTime(String pattern) This method returns a Date initialized without milliseconds. Date date = new Date(); SimpleDateFormat formatter = new SimpleDateFormat(pattern); String dateString = formatter.format(date); return dateString; |
String | getFormattedDateAndTime(final Date date) get Formatted Date And Time final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); return dateFormat.format(date); |
String | getFormattedDateTime(Date date, String pattern) get Formatted Date Time SimpleDateFormat sdfDate = new SimpleDateFormat(pattern); return sdfDate.format(date); |
String | getFormattedDateTime(String date, String dateFormat) get Formatted Date Time try { return new SimpleDateFormat(dateFormat) .format(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").parse(date)); } catch (ParseException e) { return ""; |
String | getFormattedDuration(long fromTime) get Formatted Duration long milliseconds = getDuration(fromTime); long seconds = milliseconds / MS_IN_SECOND; long minutes = seconds / SEC_IN_MINUTE; Object[] args = { Long.valueOf(minutes), Long.valueOf(seconds % SEC_IN_MINUTE) }; return TIME_FORMAT.format(args); |