List of utility methods to do Hour Format
String | formatTime(long time) Takes an elapsed time (in milliseconds) and turns it into a stopwatch style time DateFormat dateFmt = new SimpleDateFormat("HH:mm:ss"); dateFmt.setTimeZone(TimeZone.getTimeZone("GMT-0")); return dateFmt.format(new Date(time)); |
String | formatTime(long time) Format time for human readers DateFormat df = new SimpleDateFormat("HH:mm:ss.SSS"); String str = df.format(time); return str; |
String | formatTime(long time, TimeUnit unit) format Time String format = "HH:mm:ss"; if (unit.toHours(time) < 1) { format = "mm:ss"; return formatTime(time, unit, format); |
String | formatTime(String dateTimeString) Extracts hour and minutes from a dateDimestring String formattedTime = ""; SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); Date date = null; try { date = dateFormat.parse(dateTimeString); } catch (ParseException e) { e.printStackTrace(); Calendar cal = Calendar.getInstance(); cal.setTime(date); String hour; if (cal.get(Calendar.HOUR_OF_DAY) < 10) { hour = "0" + String.valueOf(cal.get(Calendar.HOUR_OF_DAY)); } else { hour = String.valueOf(cal.get(Calendar.HOUR_OF_DAY)); String minute; if (cal.get(Calendar.MINUTE) < 10) { minute = "0" + String.valueOf(cal.get(Calendar.MINUTE)); } else { minute = String.valueOf(cal.get(Calendar.MINUTE)); formattedTime = formattedTime + " " + hour + ":" + minute; return hour + ":" + minute; |
Date | formatTime_(String time) format Tim_ time = time.replaceAll("T", " "); DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss+0000"); return format.parse(time); |
String | formatTime_1(long time_value) format Tim_ time_format_1.setTimeZone(TimeZone.getTimeZone("GMT+0:00")); return time_format_1.format(new Date(time_value)); |
String | formatTime_2(long time_value, long frame_rate) format Tim_ time_format_2.setTimeZone(TimeZone.getTimeZone("GMT+0:00")); String time_str = time_format_2.format(new Date(time_value)); return (time_str.substring(0, time_str.length() - 3) + adaptString( (Integer.parseInt(time_str.substring(time_str.length() - 3)) * 90 / (int) frame_rate), 2)); |
String | formatToHour(Date date) format To Hour java.text.DateFormat format = new java.text.SimpleDateFormat("yyyyMMddHH"); return format.format(date); |
String | formatToOpenMrsDate(Date date) Parses the given Date to the String representation of that date in the format used by the OpenMRS. SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); return dateFormat.format(date.getTime()); |
String | formatToSec(Date date) format To Sec return format(date, "yyyyMMdd_HHmmss"); |