List of utility methods to do Date to Timestamp
String | timeStamp(Date date) Creates a formatted timestamp string of the given date using the local host timezone. return timeStamp(date, null);
|
String | timestamp(Date dateAndTime) Return a string holding the time and date in the form: Thursday, May 29, 2003 11:42:44 AM return DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.MEDIUM).format(dateAndTime);
|
String | timestampSec(Date date) timestamp Sec final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd-HHmmss"); return dateFormat.format(date); |
String | TimestampToString(Date thisdate) Timestamp To String if (thisdate != null) { SimpleDateFormat sdf = (SimpleDateFormat) SimpleDateFormat.getDateInstance(); sdf.applyPattern("yyyy-MM-dd HH:mm:sss"); return sdf.format(thisdate); } else { return ""; |
Date | toDate(String timeStamp) to Date try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss'.'SSS"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); return sdf.parse(timeStamp); } catch (ParseException e) { try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); ... |
String | toDateStringFromResources(String timestamp) Convert timestamp string into a localised date string SimpleDateFormat format = new SimpleDateFormat("yyyyMMddhhmmss"); Date d = null; try { d = format.parse(timestamp); } catch (ParseException e) { e.printStackTrace(); DateFormat formatter = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.getDefault()); ... |
String | toDateTime(String timeStamp) to Date Time try { Long ts = Long.parseLong(timeStamp) * 1000; DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.format(new java.util.Date(ts)); } catch (NumberFormatException e) { return ""; |
Date | unixTimestampToDate(int timestamp) unix Timestamp To Date Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(timestamp * 1000l);
return calendar.getTime();
|