List of utility methods to do Time Format
long | getTime(String dateStr, String formate) get Time Date date; try { date = getDate(dateStr, formate); return date.getTime(); } catch (ParseException e) { return -1; |
String | getTime(String format) get Time return formatDate(new Date(), format); |
long | getTime(String format, String date) get Time if (format == null || "".equals(format)) format = "yyyy-MM-dd"; SimpleDateFormat simpledateformat = new SimpleDateFormat(format, Locale.SIMPLIFIED_CHINESE); Date d = null; try { d = (Date) simpledateformat.parse(date); } catch (ParseException e) { e.printStackTrace(); ... |
String | getTime(String timeFormat) Gets the time at the instant of invocation. return new SimpleDateFormat(timeFormat).format(Calendar.getInstance().getTime()); |
String | getTimeAfter(int field, int amount, String formatStr) get Time After Calendar cal = Calendar.getInstance(); cal.add(field, amount); SimpleDateFormat sp = new SimpleDateFormat(formatStr); return sp.format(cal.getTime()); |
String | getTimeAsString(final Date date, final String format) Returns the given Date as a formatted String for the given formatting rule. SimpleDateFormat frmt = new SimpleDateFormat(format); return frmt.format(date); |
String | getTimeAsString(String timeFormatAsString) get Time As String DateFormat timeFormat = new SimpleDateFormat(timeFormatAsString); Calendar calendar = Calendar.getInstance(); return timeFormat.format(calendar.getTime()); |
String | getTimeByDate(Date date, String timeFormat) get Time By Date if (date == null) return null; if (timeFormat == null) { timeFormat = "MM/dd/yyy hh:mm:ss"; return new SimpleDateFormat(timeFormat).format(date); |
String | getTimeByFormat(Date date, String format) Gets the time by format. return format(date, format, Locale.ENGLISH);
|
long | getTimeCount(String from, String to, String format) get Time Count Date d1 = dateFormatCheck(from, format); Date d2 = dateFormatCheck(to, format); long duration = d2.getTime() - d1.getTime(); return duration; |