List of utility methods to do Long to Date Convert
int | getDay(long dateTimeMillis) get Day SimpleDateFormat format = new SimpleDateFormat("dd"); StringBuilder dateString = new StringBuilder( format.format(dateTimeMillis)); return Integer.parseInt(dateString.toString()); |
int | getDayOfWeek(long timeMillis) get Day Of Week Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(timeMillis);
return calendar.get(Calendar.DAY_OF_WEEK);
|
String | getDefaultDateTimeString(long date, Locale locale) get Default Date Time String return getDateTimeString(new Date(date), DateFormat.DEFAULT, locale); |
String | getDefaultDatetime(long milliseconds) get Default Datetime Date date = new Date(milliseconds); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); return sdf.format(date); |
String | getElapsedDurationSince(long seconds) get Elapsed Duration Since String unit = SECOND; String residueUnit = null; long currentTimeInSeconds = System.currentTimeMillis() / 1000; long elapsedTimeInSeconds = currentTimeInSeconds - seconds; int count = 0; int residue = 0; if (elapsedTimeInSeconds > SECONDS_IN_MIN && elapsedTimeInSeconds < SECONDS_IN_HOUR) { ... |
String | getFormattedTime(String dateTimeFormat, long timestamp) Method to get the current date-time in the input format. Date date = new Date(timestamp); SimpleDateFormat sdf = new SimpleDateFormat(dateTimeFormat, Locale.US); return sdf.format(date); |
String | getFriendlyDate(Context context, long timestamp) Returns date from given @param timestamp in friendly format. if (timestamp < 0) return ""; if (sResources == null) { sResources = context.getResources(); final long now = System.currentTimeMillis(); final long offset = sTimeZone.getOffset(now); final long diff = now - offset - timestamp; ... |
int | getHour(long dateTimeMillis) get Hour SimpleDateFormat format = new SimpleDateFormat("HH"); StringBuilder dateString = new StringBuilder( format.format(dateTimeMillis)); return Integer.parseInt(dateString.toString()); |
int | getHour(long timeMillis) get Hour Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(timeMillis);
return calendar.get(Calendar.HOUR_OF_DAY);
|
String | getHoursAndMinutes(long dateTimeMillis) get Hours And Minutes String format = String.format("%%0%dd", 2); long elapsedTime = dateTimeMillis / 1000; String minutes = String.format(format, (elapsedTime % 3600) / 60); String hours = String.format(format, elapsedTime / 3600); return hours + ":" + minutes; |