List of utility methods to do Date to Time
String | extractTimeFromDate(Date date) extract Time From Date SimpleDateFormat printFormat = new SimpleDateFormat("HH:mm:ss"); return printFormat.format(date); |
String | getFriendlyTime(Date dateTime) get Friendly Time StringBuffer sb = new StringBuffer(); Date current = Calendar.getInstance().getTime(); long diffInSeconds = (current.getTime() - dateTime.getTime()) / 1000; long sec = (diffInSeconds >= 60 ? diffInSeconds % 60 : diffInSeconds); long min = (diffInSeconds = (diffInSeconds / 60)) >= 60 ? diffInSeconds % 60 : diffInSeconds; long hrs = (diffInSeconds = (diffInSeconds / 60)) >= 24 ? diffInSeconds % 24 : diffInSeconds; long days = (diffInSeconds = (diffInSeconds / 24)) >= 30 ? diffInSeconds % 30 : diffInSeconds; long months = (diffInSeconds = (diffInSeconds / 30)) >= 12 ? diffInSeconds % 12 : diffInSeconds; ... |
String | getFriendlyTimeString(Date date) get Friendly Time String return friendlyTimeFormat.format(date);
|
String | getMediumDateString(Date date, boolean includeTime) Returns medium date string representation in localized format (e.g. if (includeTime) { return getDateTimeString(date, DateFormat.MEDIUM, DateFormat.SHORT); } else { return getDateString(date, DateFormat.MEDIUM); |
String | getMSDateTimeString(Date date) MSTYPE yyyy-MM-dd hh:mm:ss return String result = null; if (date != null) { result = msfLong.format(date); return result; |
String | getTime(Date date) get Time SimpleDateFormat formatter_f = new SimpleDateFormat("yyyy-MM-dd"); String str = formatter_f.format(date); return str; |
String | getTime(Date date) get Time String DATE_FORMAT = "HH:mm:ss"; java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT); String formattedTime = sdf.format(date); return formattedTime; |
String[] | getTime(Date date) get Time String[] time = new String[2]; Calendar cal = Calendar.getInstance(); cal.setTime(date); time[0] = Integer.toString(cal.get(Calendar.HOUR_OF_DAY)); time[1] = Integer.toString(cal.get(Calendar.MINUTE)); return time; |
String | getTime(Date date) Return the current Time return new SimpleDateFormat("HH:mm:ss").format(date); |
String | getTime(Date date) get Time sFormat = new SimpleDateFormat(TIME_FORMAT, Locale.CHINA); return sFormat.format(date); |