Java Utililty Methods Date Parse

List of utility methods to do Date Parse

Description

The list of methods to do Date Parse are organized into topic(s).

Method

DatedateFromString(String s)
Get a date from a String.
if (s == null) {
    return null;
try {
    if (s.matches(DATE_REGEX)) {
        return DATE_FORMAT.parse(s);
    } else if (s.matches(DATE_TIME_REGEX)) {
        return DATE_TIME_FORMAT.parse(s);
...
DatedateFromString(String value)
date From String
try {
    StringTokenizer st = new StringTokenizer(value, ",");
    String dateFormat = _dateFormat;
    String dateAsString = null;
    if (st.hasMoreTokens()) {
        dateFormat = st.nextToken();
    if (st.hasMoreTokens()) {
...
DateDateFromStringFormat(final String date, final String format)
Date From String Format
if (date == null) {
    throw new NullPointerException("DateUtil: DateFromStringFormat: date == null");
if (format == null) {
    throw new NullPointerException("DateUtil: DateFromStringFormat: format == null");
DateFormat dateFormat = new SimpleDateFormat(format, Locale.ENGLISH);
return dateFormat.parse(date);
...
DatedateFromW3CDTF(String date)
Creates a Date object from the string passed to it.
int len = date.length();
if (len > 5 && date.charAt(len - 3) == ':') {
    char c = date.charAt(len - 6);
    if (c == '+' || c == '-')
        date = date.substring(0, len - 3) + date.substring(len - 2);
return (Date) w3cdtf.get().parseObject(date);
DatedateParse(String date)
Parse a date string into an object.
DateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
return sdf.parse(date);
DatedateParse(String date2BeParsed)
Parse String parameter as a Date with dd/MM/YYYY-HH:mm:ss format
Date parsedDate = null;
DateFormat df = new SimpleDateFormat("dd/MM/YYYY-HH:mm:ss:S");
parsedDate = df.parse(date2BeParsed);
return parsedDate;
DatedateParseFromMyJsFormat(String jsDate)
Parse date from my string format to Data source string example - '2014-02-13_00.00.00'
if (jsDate.split("_")[1].length() == 5) {
    jsDate += ".00";
return MY_JS_DATE_FORMAT.parse(jsDate);
SimpleDateFormatdateParser()
date Parser
SimpleDateFormat dateParser = new SimpleDateFormat(DATE_FORMAT);
dateParser.setTimeZone(TIME_ZONE);
return dateParser;
StringdateParser(Date date)
date Parser
if (date == null) {
    return "";
Calendar cal = Calendar.getInstance();
String dateStr = "";
cal.setTime(date);
int day = cal.get(Calendar.DAY_OF_MONTH);
int month = cal.get(Calendar.MONTH) + 1;
...
StringdateParser(String dateStr, String inputDateFormat, String outputDateFormat)
date Parser
String formattedDate = null;
SimpleDateFormat parseFormat = null;
parseFormat = new SimpleDateFormat(inputDateFormat);
Date inDate = parseFormat.parse(dateStr);
SimpleDateFormat displayFormat = new SimpleDateFormat(outputDateFormat);
formattedDate = displayFormat.format(inDate);
return formattedDate;