List of utility methods to do Time Parse
String | getTimeFileName(String suffix) get Time File Name return formatDate(new Date(), "yyyyMMddHHmmssSSS") + suffix; |
Date | getTimeFromGermanLocale(String timeString) Creates a date time value from a string. try { return germanTime.parse(timeString); } catch (Exception e) { return null; |
Date | getTimeFromJsToJava(String date) get Time From Js To Java SimpleDateFormat utcFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.CHINA); utcFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Date d = null; try { d = utcFormat.parse(date); } catch (Exception e) { e.printStackTrace(); return d; |
long | getTimeFromString(String time) get Time From String SimpleDateFormat format = new SimpleDateFormat(dateFormatString); try { Date date = format.parse(time); return date.getTime(); } catch (Exception e) { throw new RuntimeException(e); |
List | getTimeList(String start, String end, int pitch) get Time List List<String> result = new ArrayList<String>(); SimpleDateFormat formatter = new SimpleDateFormat("HH:mm"); try { Date startDate = formatter.parse(start); Date endDate = formatter.parse(end); Calendar startCalendar = Calendar.getInstance(); Calendar endCalendar = Calendar.getInstance(); startCalendar.setTime(startDate); ... |
String | getTimeStr(String date1, String date2) get Time Str SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); try { long time = format.parse(date1).getTime() - format.parse(date2).getTime(); long time1 = format.parse("1970-01-01 00:00:00").getTime() + time; return formatDate(new Date(time1), "HH:mm:ss"); } catch (ParseException e) { e.printStackTrace(); return ""; |
long | getTimeWithStr(String source, String pattern) get Time With Str return new SimpleDateFormat(pattern).parse(source).getTime(); |
long | getTimeX(String dateStr) get Time X long time = 0; time = getDate(dateStr).getTime() / 1000; return time; |
boolean | isDateTime(String dateTime) is Date Time int first = dateTime.indexOf(":"); int last = dateTime.lastIndexOf(":"); if (first == -1) { return false; SimpleDateFormat df = null; if (first == last) { df = new SimpleDateFormat("yyyy-MM-dd hh:mm"); ... |
boolean | isDateTime(String dateTime, String pattern) is Date Time DateFormat df = new SimpleDateFormat(pattern); ParsePosition pos = new ParsePosition(0); Date dt = df.parse(dateTime, pos); return !(dt == null); |