List of utility methods to do String to Time
Date | string2DateTime(String stringDate) string Date Time if (stringDate == null) { return null; return getFormat(simple).parse(stringDate); |
Date | string2DateTimeByAutoZero(String stringDate) string Date Time By Auto Zero if (stringDate == null) { return null; if (stringDate.length() == 11) stringDate = stringDate + "00:00:00"; else if (stringDate.length() == 13) stringDate = stringDate + ":00:00"; else if (stringDate.length() == 16) ... |
Calendar | stringToCalendar(String stringTime) string To Calendar return stringToCalendar(stringTime, "yyyyMMddHHmmss"); |
Calendar | stringToCalendar(String timeStr) string To Calendar Date date = stringToTime(timeStr);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar;
|
Date | stringToTimeDate(String timeStr) string To Time Date return formatStrToDate(FORMATO_HORA, timeStr);
|
Date | toTime(final String dateString) Tries to interpret a given string as a timestamp This routines assumes that all date parts of a day are present, including time components. if (dateString == null || dateString.trim().length() < 6) return null; Locale[] locales = { Locale.getDefault(), Locale.UK, Locale.GERMANY }; for (Locale locale : locales) { if (!TIME_PATTERNS.containsKey(locale)) { List<SimpleDateFormat> patterns = new ArrayList<SimpleDateFormat>(); for (String pattern : TIME_FORMATS) { patterns.add(new SimpleDateFormat(pattern, locale)); ... |
long | toTime(String display) Convert between time as a String to milliseconds in a "static" way (to exchange data over the wire, for instance). SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { return sdf.parse(display).getTime(); } catch (ParseException e) { return -1; |
Date | toTime(String str) Parses a String as an SQL time. synchronized (time_format_sql) { for (int i = 0; i < time_format_sql.length; ++i) { try { return time_format_sql[i].parse(str); } catch (ParseException e) { throw new RuntimeException(dateErrorString("Unable to parse string as a time ", time_format_sql)); ... |