List of utility methods to do Long to Date Convert
Date | GetDate(long milliseconds) Get Date return new Date(milliseconds); |
long | convToEnglishTime(long dateMsec) conv To English Time Time androTime; androTime = new Time(); androTime.switchTimezone(TimeZone.getDefault().getDisplayName( Locale.ENGLISH)); androTime.set(dateMsec); return androTime.normalize(true); |
String | converTime(long timestamp, String[] timeLabels) conver Time long currentSeconds = System.currentTimeMillis() / 1000; long timeGap = currentSeconds - timestamp; String timeStr = null; if (timeGap > 24 * 60 * 60) { timeStr = timeGap / (24 * 60 * 60) + timeLabels[0]; } else if (timeGap > 60 * 60) { timeStr = timeGap / (60 * 60) + timeLabels[1]; } else if (timeGap > 60) { ... |
String | convertNotNull(Long long1) convert Not Null String str = String.valueOf(long1); if (StringUtils.isEmpty(str) || long1.equals("0")) { return "null"; Date date = parseDate(str); if (date == null) { return "null"; } else { ... |
String | convertToDateStamp(long time) Convert given date to string OutputFormat: yyyymmdd_hhmm Calendar cal = Calendar.getInstance(); cal.setTime(new Date(time)); return convertToDateStamp(cal); |
String | convertToTimeStamp(long time) Convert date to short time string return convertToTimeStamp(time, true);
|
String | convertToTimeStamp(long time, boolean showSeconds) Convert date to short time string return convertToTimeStamp(new Date(time), showSeconds); |
Date | dateFromUnixTimestamp(final long unixTimestamp) date From Unix Timestamp final Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(unixTimestamp * 1000); return cal.getTime(); |
Date | dateFromUtc(long milliseconds) date From Utc Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC")); cal.setTimeInMillis(milliseconds); return cal.getTime(); |
String | dateUtil(long date) date Util Date d = new Date(); d.setTime(date); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", java.util.Locale.getDefault()); String str = sdf.format(d); return str; |