Android Utililty Methods Long to Date Convert

List of utility methods to do Long to Date Convert

Description

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

Method

DategetDateForMillis(final long tick)
get Date For Millis
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(tick);
return cal.getTime();
StringgetDateLabel(long date)
get Date Label
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
return sdf.format(date);
StringgetDateString(long date, int style, Locale locale)
get Date String
DateFormat formatter = DateFormat.getDateInstance(style, locale);
return formatter.format(date);
StringgetDateString(long time)
get Date String
Calendar date = Calendar.getInstance();
time = time * 1000;
date.setTimeInMillis(time);
SimpleDateFormat dateformat = new SimpleDateFormat(
        "yyyy-MM-dd HH:mm");
String dateString = dateformat.format(date.getTime());
return dateString;
StringgetDateTime(long microsecond)
get Date Time
return getFormatDateTime(new Date(microsecond),
        "yyyy-MM-dd HH:mm:ss");
StringgetDateTime(long microsecond)
get Date Time
return getFormatDateTime(new Date(microsecond),
        "yyyy-MM-dd HH:mm:ss");
DategetDateTimeForTimeZone(Long time)
get Date Time For Time Zone
Long sourceRelativelyGMT = time
        - TimeZone.getTimeZone(DEFAULT_TIMEZONE).getRawOffset();
Long targetTime = sourceRelativelyGMT
        + TimeZone.getDefault().getRawOffset();
Date date = new Date(targetTime);
return date;
StringgetDateTimeLabel(long time)
get Date Time Label
SimpleDateFormat formatter = new SimpleDateFormat(DATE_TIME_FORMAT);
return formatter.format(new Date(time));
StringgetDateTimeString(long dateTime)
get Date Time String
SimpleDateFormat format = new SimpleDateFormat("HH:mm dd/MM/yy");
StringBuilder dateString = new StringBuilder(
        format.format(dateTime));
return dateString.toString();
StringgetDateWeekLabel(long date)
get Date Week Label
SimpleDateFormat sdf = new SimpleDateFormat(DATE_WEEK_FORMAT);
return sdf.format(date);