List of utility methods to do String to Date
Date | strToDate(String time, String format) Convert String of day to Date type DateFormat formater = new SimpleDateFormat(format); return formater.parse(time); |
String | strToDate3(String i_StrDate) str To Date try { if (i_StrDate == null || "".equals(i_StrDate.trim())) { return ""; java.util.Date d = SDF_FULL.parse(i_StrDate); return SDF_FULL.format(d); } catch (Exception e) { e.printStackTrace(); ... |
Date | strToDateM6(String StrToDate) StrToDate 'yyyy-MM-dd HH:mm:ss' SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); try { return simpleDateFormat.parse(StrToDate); } catch (ParseException e) { return null; |
Date | StrToDateSeco(String str) Str To Date Seco Date parse = null; try { parse = seconParse.parse(str); } catch (ParseException e) { e.printStackTrace(); return parse; |
Date | strToDatetime(String sStr) str To Datetime if (sStr == null) { return null; SimpleDateFormat formatter; if (sStr.length() == 19) { formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); } else if (sStr.length() == 10) { formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); ... |
Date | strToDateWithFormat(String strDate, Format format) str To Date With Format SimpleDateFormat localFormat = (SimpleDateFormat) format; ParsePosition pos = new ParsePosition(0); Date strtodate = localFormat.parse(strDate, pos); return strtodate; |
Date | TimeStringToDate(String s) Time String To Date Date date = new Date(); try { SimpleDateFormat simpledateformat = new SimpleDateFormat("HH:mm:ss"); ParsePosition parseposition = new ParsePosition(0); date = simpledateformat.parse(s, parseposition); } catch (Exception ex) { return date; ... |
Date | timeToDate(String time) time To Date Date fecha = null; try { SimpleDateFormat sdf; if (time.length() == 5) { sdf = new SimpleDateFormat("HH:mm"); } else if (time.length() == 8) { sdf = new SimpleDateFormat("HH:mm:ss"); } else { ... |
Date | toDate(DateFormat format, String value) to Date return toDate(format, value, null);
|
String | toDate(final Long date, final String pattern) to Date final long millis = Long.valueOf(date).longValue() * 1000; final Date d = new Date(millis); final SimpleDateFormat sdf = new SimpleDateFormat(pattern); return sdf.format(d); |