List of utility methods to do Millisecond Convert
Long | getTimeInMillisFromNicsDateString(String dateString) get Time In Millis From Nics Date String Long ret = null; DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); formatter.setTimeZone(TimeZone.getTimeZone("UTC")); Date date; try { date = (Date) formatter.parse(dateString); DateTime dt = new DateTime(date); ret = dt.getMillis(); ... |
long | getTimeMillis(String dateStr) get Time Millis return convertStrToDate(dateStr, "yyyy-MM-dd HH:mm:ss").getTime(); |
long | getTimeMillis(String time) get Time Millis try { DateFormat dateFormat = new SimpleDateFormat("yy-MM-dd HH:mm:ss"); DateFormat dayFormat = new SimpleDateFormat("yy-MM-dd"); Date curDate = dateFormat.parse(dayFormat.format(new Date()) + " " + time); return curDate.getTime(); } catch (ParseException e) { e.printStackTrace(); return 0; |
String | getTimestamp(long milliseconds) get Timestamp SimpleDateFormat dformat = new SimpleDateFormat("YYYY:MM:dd:HH:mm:ss:SS"); Date d = new Date(milliseconds); String dstr = dformat.format(d); return dstr; |
String | getTimestampMillis(Locale locale) Gets timestamp millis. return new SimpleDateFormat("yyyyMMddhhmmssSSS", locale).format(new Date()); |
String | getTimeStr(final long millis) get Time Str long minutes = TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)); long hours = TimeUnit.MILLISECONDS.toHours(millis); StringBuilder b = new StringBuilder(); b.append(hours == 0 ? "" : String.valueOf(hours) + "h"); b.append(minutes == 0 ? "" : String.valueOf(minutes) + "m"); long seconds = millis - TimeUnit.MINUTES.toMillis(TimeUnit.MILLISECONDS.toMinutes(millis)); b.append(secondFormat.format(seconds / 1000.0) + "s"); ... |
String | getTimeString(long millis) get Time String Date date = new Date(millis); return sdf.format(date); |
String | getTimeString(long timelnMillis) get Time String Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(timelnMillis); Date date = calendar.getTime(); SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd"); String newTypeDate = f.format(date); return newTypeDate; |
String | getTimeTakenAsSecondsString(long timeTakenMillis) get Time Taken As Seconds String String result = "0"; if (timeTakenMillis > 0) { float timeSeconds = timeTakenMillis / 1000f; result = getSecondsFormatter().format(timeSeconds); return result; |
String | millisecondConvertToStringTime(final long milliseconds) Convert the millisecond to String time. DateFormat formatterTimeGMT = new SimpleDateFormat(TIME_FORMAT); formatterTimeGMT.setTimeZone(TimeZone.getTimeZone(TIME_ZONE_GMT)); Date date = new Date(); date.setTime(milliseconds); String timeString = formatterTimeGMT.format(date); return timeString; |