List of utility methods to do Time Get
String | getCurrentTime() get Current Time SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss.SSS"); Date date = new Date(System.currentTimeMillis()); return sdf.format(date); |
String | Now(String time) Now SimpleDateFormat formatter = new SimpleDateFormat( "yyyyMMdd hhmmss"); SimpleDateFormat formatter2 = new SimpleDateFormat( "yyyy-MM-dd hh:mm:ss"); Date curDate; try { curDate = formatter.parse(time); return formatter2.format(curDate); ... |
String | toTime(int time) to Time time /= 1000; int minute = time / 60; int hour = minute / 60; int second = time % 60; minute %= 60; return String.format("%02d:%02d", minute, second); |
String | getCurrentTime() get Current Time return getCurrentTime("yyyyMMddHHmmss"); |
String | intConvertTime(int hour, int minut) int Convert Time StringBuilder time = new StringBuilder(); time.append(hour / 10 % 10); time.append(hour % 10); time.append(":"); time.append(minut / 10 % 10); time.append(minut % 10); return time.toString(); |
String | getCurrentTime(String format) get Current Time SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(new Date()); |
String | getCurrentTimeString() get Current Time String Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); String second = cal.get(Calendar.SECOND) < 10 ? "0" + cal.get(Calendar.SECOND) : "" + cal.get(Calendar.SECOND); String minute = cal.get(Calendar.MINUTE) < 10 ? "0" + cal.get(Calendar.MINUTE) : "" + cal.get(Calendar.MINUTE); String hour = cal.get(Calendar.HOUR_OF_DAY) < 10 ? "0" + cal.get(Calendar.HOUR_OF_DAY) : "" ... |
String | getCurrentDateTime() get Current Date Time return getFormatDateTime(new Date(), "yyyy-MM-dd HH:mm:ss"); |
String | getCurrentTime() get Current Time return getFormatDateTime(new Date(), "yyyy-MM-dd HH:mm:ss"); |
String | getFormatShortTime(Date date) get Format Short Time return getFormatDateTime(date, "yyyy-MM-dd"); |