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

StringgetDT(long mills)
get DT
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.JAPAN);
return sdf.format(mills);
StringgetDuration(long time)
get Duration
NumberFormat f = NumberFormat.getInstance();
f.setMinimumIntegerDigits(2);
int milliseconds = (int) (time % 1000);
time /= 1000;
int seconds = (int) time % 60;
time /= 60;
int minutes = (int) time % 60;
time /= 60;
...
StringgetElapsedTime(long start, long end)
get Elapsed Time
Calendar result = Calendar.getInstance();
long sa = end - start - result.getTimeZone().getRawOffset();
result.setTimeInMillis(sa);
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
return sdf.format(result.getTime());
StringgetElapsedTime(long startTime, long finishTime)
get Elapsed Time
if (startTime == 0) {
    return "-";
return finishTime == 0 ? decimalF.format((System.currentTimeMillis() - startTime) / 1000) + " sec"
        : decimalF.format((finishTime - startTime) / 1000) + " sec";
StringgetElapsedTimeSpecificationDescription(long sizeInBytes)
Returns a short string description of the size, in bytes, specified.
return getElapsedTimeSpecificationDescription(sizeInBytes, "#.##");
StringgetExpires(long maxAge)
get Expires
long created = System.currentTimeMillis();
Date expiredate = new Date(created + (maxAge * 1000));
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
return sdf.format(expiredate);
StringgetHMSFromMills(long millSec)
get HMS From Mills
String retval;
int decimal = (int) (millSec % 1000);
int seconds = (int) (millSec / 1000);
if (seconds > 0) {
    if (seconds < 60) {
        retval = seconds + "." + decimal + " sec";
    } else {
        String outStr = getHMS(seconds);
...
StringgetOldCookieDate(long time)
Returns a formated date and time String form a timestamp value based on the (old) Netscape cookie date format.

if (OLD_COOKIE.getTimeZone() != GMT_TIMEZONE) {
    OLD_COOKIE.setTimeZone(GMT_TIMEZONE);
return OLD_COOKIE.format(new Date(time));
StringgetReadableDate(long longTime)
get Readable Date
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date(longTime);
return dateFormat.format(date);
StringgetServerTime(long offset)
Get a String containing the current timestamp of the server, for use in the HTTP Date header and caching headers.
Calendar calendar = Calendar.getInstance();
Date outDate = new Date(calendar.getTime().getTime() + (offset * 1000));
return dateFormat.format(outDate);