List of utility methods to do String to Timestamp
String | calculateClientRequestId(String timestamp) This method is used to calculate the clientRequestId parameter of a request. try { return String.valueOf(sdf.parse(timestamp).getTime()); } catch (ParseException e) { return "-1"; |
String | getFileNameWithTimeStampInterposed(final String fileName) Interpose a time stamp between the file name and extension String namePart = getFileNameUpToExtension(fileName); String extension = getFileExtension(fileName); StringBuilder newName = new StringBuilder(namePart); newName.append(".[backup from - "); DateFormat dateFormat = DateFormat.getDateTimeInstance(); newName.append(dateFormat.format(new Date())); newName.append("]"); newName.append(extension); ... |
long | getStringToTimestamp(String string) return unix timestamp of specified string value in format: yyyy-MM-dd HH:mm:ss try { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); ParsePosition parsePosition = new ParsePosition(0); Date date = simpleDateFormat.parse(string, parsePosition); return date.getTime(); } catch (Exception e) { return -1; |
String | getTimeStamp(String date) get Time Stamp SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd"); ParsePosition pos = new ParsePosition(0); Date d = formatter.parse(date, pos); return String.valueOf(d.getTime()); |
String | getTimeStamp(String dateTime) get Time Stamp SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd hh:mm:ss"); Date date = null; try { date = sdf.parse(dateTime); } catch (ParseException e) { e.printStackTrace(); Calendar calendar = Calendar.getInstance(); ... |
long | getTimestamp(String dateValue, String pattern, TimeZone timezone) get Timestamp DateFormat d = new SimpleDateFormat(pattern); Calendar c = Calendar.getInstance(timezone); c.setTime(d.parse(dateValue)); return c.getTimeInMillis(); |
String | getTimestamp(String pattern) get Timestamp return getTime(new Date(), pattern, currentLocale); |
long | getTimeStamp(String pattern, String strDate) get Time Stamp long returnTimeStamp = 0; Date aDate = null; try { aDate = convertStringToDate(pattern, strDate); } catch (ParseException pe) { aDate = null; if (aDate == null) { ... |
String | getTimeStamp(String style, Date date) get Time Stamp DateFormat format = new SimpleDateFormat(style); return format.format(date); |
String | getTimestamp(String timeStampStr, String logRundateIdStr) get Timestamp SimpleDateFormat timeDf = new SimpleDateFormat("yyyyMMdd"); String resultValue = "0"; try { new Date(Long.valueOf(timeStampStr) * 1000); resultValue = timeStampStr; } catch (NumberFormatException e) { try { Date date = timeDf.parse(logRundateIdStr); ... |