List of utility methods to do String to Time
Date | getAsDateTime(String dateTime) get As Date Time try { return new SimpleDateFormat(FORMAT).parse(dateTime); } catch (ParseException e) { throw new IllegalArgumentException(e); |
Calendar | getCalendarForSpecifiedDate(final String dateTime) Gets the calendar for specified date. final Calendar calTime = Calendar.getInstance(); final SimpleDateFormat sdf = new SimpleDateFormat(DATE_FMT_FULL, Locale.ENGLISH); final Date date = (Date) sdf.parse(dateTime); calTime.setTime(date); return calTime; |
Calendar | getCalendarFromCPEGeneratorDateTime(String cpeDateTime) Take a value of a cpe dictionary's generator timestamp and return a Calendar object. Calendar c = null; String dateFormatString = "yyyy-MM-dd'T'hh:mm:ss"; try { SimpleDateFormat sdf = new SimpleDateFormat(dateFormatString); Date d = sdf.parse(cpeDateTime); c = Calendar.getInstance(); c.setTime(d); } catch (Exception e) { ... |
Calendar | getCalendarFromDate(final String dateTime) getCalendarFromDate. final Calendar cal = GregorianCalendar.getInstance(); final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { final Date date = sdf.parse(dateTime); cal.setTime(date); } catch (final ParseException e) { return null; return cal; |
String | getDlayDateTime(String playDate, String playTime) get Dlay Date Time SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat format2 = new SimpleDateFormat("HH:mm:ss"); StringBuffer sb = new StringBuffer(); try { playDate = format1.format(format.parse(playDate)); } catch (ParseException e) { e.printStackTrace(); ... |
String | getEndTime(String flag, int value) get End Time Calendar calendar = Calendar.getInstance(); if (flag.equals("DAY")) { calendar.add(Calendar.DAY_OF_MONTH, -value); } else if (flag.equals("HOUR")) { calendar.add(Calendar.HOUR_OF_DAY, -value); } else if (flag.equals("MINUTE")) { calendar.add(Calendar.MINUTE, -value); Date dateTime = calendar.getTime(); return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(dateTime); |
Date | getExecutionDateTime(String input) get Execution Date Time return executionFormat.parse(input);
|
Date | getExpireTime(String timeStr) get Expire Time SimpleDateFormat formatter = new SimpleDateFormat(dateFormat); Date date = formatter.parse(timeStr, new ParsePosition(0)); return date; |
String | getFormerDate(String dateTime) get Former Date SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); long dif = df.parse(dateTime).getTime() - 86400 * 1000; Date date = new Date(); date.setTime(dif); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); return sdf.format(date); |
String | getIdByTime(String name) get Id By Time return name + "-" + getCurrDate() + "-" + getCurrTime() + "-" + getRandomNumber(); |