List of utility methods to do String to Time
String | getTime(String pattern) get Time Date now = new Date(); SimpleDateFormat sdf = new SimpleDateFormat(pattern); return sdf.format(now); |
long | getTime(String s) get Time return parseMysql(s).getTime();
|
int | getTime(String sDateTime, String eDateTime) get Time SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd"); java.util.Date ssDateTime = myFormatter.parse(sDateTime); java.util.Date eeDateTime = myFormatter.parse(eDateTime); long l = (eeDateTime.getTime() - ssDateTime.getTime()); long day = l / (24 * 60 * 60 * 1000); return (int) day; |
long | getTime(String time) get Time SimpleDateFormat shijian = new SimpleDateFormat("yyyy-MM-dd"); long longtime = 0; try { longtime = shijian.parse(time).getTime(); } catch (Exception e) { return longtime; |
Date | getTime(String time) get Time return getDateTime(time, DEFAULT_FORMAT_TIME);
|
Date | getTimeDate(String time) get Time Date String string = sdf.format(getCurrentDateTime()); string += " " + time; Date date = null; try { date = sdf2.parse(string); } catch (ParseException e) { e.printStackTrace(); return date; |
List | getTimes(String startTime, String endTime) get Times List<String> dayList = new ArrayList<String>(); try { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Date startDate = df.parse(startTime); Date endDate = df.parse(endTime); String now = ""; for (long i = startDate.getTime(); i <= endDate.getTime(); i += (long) 24 * (long) 3600 * (long) 1000) { Date date = new Date(i); ... |
String | replaceDateTime(String input) * If the input String contains the sequence {date}pattern{date}, replaces the first occurrence of this sequence with a UTC date/time string formatted according to pattern. String output = input; try { String token = "{date}"; if (isNonEmptyString(output) && output.contains(token)) { int tlen = token.length(); StringBuilder sb = new StringBuilder(output); int p1f = sb.indexOf(token); while (p1f > -1) { ... |
Date | str2DateTime(String strDate) yyyy-MM-dd HH:mm:ss DateFormat df = DateFormat.getDateTimeInstance(); Date date = null; try { date = df.parse(strDate); } catch (ParseException e) { e.printStackTrace(); return date; ... |
Date | string2Date(String time) string Date DateFormat dateFormat = new SimpleDateFormat("yyyyMMddhhssmm"); Date date = new Date(); try { date = dateFormat.parse(time); } catch (ParseException e) { e.printStackTrace(); return date; ... |