Java Utililty Methods Long Number to Date

List of utility methods to do Long Number to Date

Description

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

Method

StringformatDate(final long timestamp)
Formats a timestamp as a human readable date.
final Calendar now = Calendar.getInstance();
final Date date = new Date(timestamp);
final Calendar cal = Calendar.getInstance();
cal.setTime(date);
final SimpleDateFormat dateFormat = getFormatForTimestamp(now, cal);
return dateFormat.format(date);
StringformatDate(long absTime)
From input time in nanoseconds, convert to Date format YYYY-MM-dd
String sdate = sdateformat.format(new Date((long) (absTime * 1E-6)));
return sdate;
StringformatDate(long d)
format Date
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(d);
SimpleDateFormat date = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");
return date.format(calendar.getTime());
StringformatDate(long d)
Convert date to String like "yyyy-MM-dd".
return new SimpleDateFormat(DATE_FORMAT).format(d);
StringformatDate(long date)
format Date
return formatDate(new Date(date));
StringformatDate(long date)
Formats and returns a given Date
SimpleDateFormat sdf = new SimpleDateFormat();
return sdf.format(new Date(date));
StringformatDate(long date)
format Date
return formatDate(new Date(date), DEFAULT_DATE_PATTERN);
StringformatDate(long date)
Returns a formatted date.
The pattern is: yyyy-MM-dd,HH:mm:ss
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd,HH:mm:ss");
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(date * 1000);
return format.format(cal.getTime());
StringformatDate(long date)
format Date
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
System.out.println(formatter.format(date));
return formatter.format(date);
StringformatDate(long date)
format Date
return formatDate(new Date(date), "yyyy-MM-dd HH:mm:ssZ");