Java Parse Date parseDate(String representedValue)

Here you can find the source of parseDate(String representedValue)

Description

parse Date

License

Apache License

Declaration

private static Date parseDate(String representedValue) throws ParseException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public final static String[] TIMEPATTERNS = { "yyyy-MM-ddtHH:mm:ss.SSXXX", "yyyy-MM-dd HH:mm:ss.SS X",
            "yyyy-MM-ddTHH:mm:ss.SX", "yyyy-MM-dd HH:mm:ss.SS", "yyyy-MM-dd" };

    private static Date parseDate(String representedValue) throws ParseException {
        Date date = null;//from   w  ww  .  ja  v  a  2 s.co  m
        for (final String pattern : TIMEPATTERNS) {
            try {
                date = new SimpleDateFormat(pattern).parse(representedValue);
            } catch (final Exception e) {
                // empty
            }
            if (date != null) {
                return date;
            }
        }
        return date;
    }
}

Related

  1. parseDate(String in)
  2. parseDate(String input)
  3. parseDate(String line)
  4. parseDate(String myDate, String pattern)
  5. parseDate(String partten, String datatime)
  6. parseDate(String s)
  7. parseDate(String s)
  8. parseDate(String s)
  9. parseDate(String s)