Java Utililty Methods Long Number to Time

List of utility methods to do Long Number to Time

Description

The list of methods to do Long Number to Time are organized into topic(s).

Method

StringgetShortTimeText(Long oldTime)
get Short Time Text
Date time = parseDate(oldTime, TimeFormat);
Date now = new Date();
String format = "yyyy-MM-dd HH:mm";
if (time.getYear() == now.getYear()) {
    format = format.substring("yyyy-".length());
    if (time.getMonth() == now.getMonth() && time.getDay() == now.getDay()) {
        format = format.substring("MM-dd ".length());
return formatDate(time, format);
StringgetSimpleDate(long time)
get Simple Date
DateFormat dateFormat = new SimpleDateFormat("dd MMM yyyy");
Date date = new Date(time);
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
return dateFormat.format(date);
StringgetSMillon(long time)
get S Millon
return new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss-SSS").format(time);
StringgetSpeedString(long castTime, long bytes)
get Speed String
double castSecond = (double) castTime / (double) 1000;
return parseSpeedString((long) ((double) bytes / castSecond) / 1024);
StringgetStrDateForLong(long time)
get Str Date For Long
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(time);
return getDefaultFormatByDate(calendar.getTime());
StringgetTextDate(long timeInMs)
get Text Date
return getTextDate((new Date(timeInMs)));
StringgetTime(long nanos)
Transforms a number of nano-seconds into a string representing from milliseconds to minutes.
NumberFormat doubleFormat = NumberFormat.getNumberInstance();
doubleFormat.setMaximumFractionDigits(2);
double millis = (double) nanos / 1000000;
if (millis < 1000) {
    return doubleFormat.format(millis) + "ms";
double secs = millis / 1000;
if (secs < 60) {
...
StringgetTime(Long time)
get Time
Date d = new Date(time);
Format simpleFormat = new SimpleDateFormat("E dd MMM yyyy hh:mm:ss a");
String date = simpleFormat.format(d);
return date;
StringgetTime(long time, boolean getTimeOnly, boolean fileSystemSafe)
get Time
return new SimpleDateFormat(
        getTimeOnly ? "HH-mm-ss" : fileSystemSafe ? "MM-dd-yyyy_HH.mm.ss" : "MM/dd/yyyy'\t'h:mm:ss a")
                .format(new Date(time));
StringgetTimeFromLong(long diff)
Returns a formatted String from time.
final String HOURS = "h";
final String MINUTES = "min";
final long MS_IN_A_DAY = 1000 * 60 * 60 * 24;
final long MS_IN_AN_HOUR = 1000 * 60 * 60;
final long MS_IN_A_MINUTE = 1000 * 60;
final long MS_IN_A_SECOND = 1000;
diff = diff % MS_IN_A_DAY;
long numHours = diff / MS_IN_AN_HOUR;
...