Java Parse Date parseDate(String s)

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

Description

parse Date

License

Apache License

Declaration

public static java.util.Date parseDate(String s) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright 2014 Miami-Dade County/*from   ww w  . java  2 s .  c  o  m*/
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.HashSet;
import java.util.Set;

public class Main {
    private static final ThreadLocal<SimpleDateFormat> ISO_DATE_FORMATS = new ThreadLocal<SimpleDateFormat>();
    public static final String isoDatePattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";

    public static java.util.Date parseDate(String s) {
        try {
            SimpleDateFormat myDateFormat = ISO_DATE_FORMATS.get();
            if (myDateFormat == null) {
                myDateFormat = new SimpleDateFormat(isoDatePattern);
                ISO_DATE_FORMATS.set(myDateFormat);
            }
            return myDateFormat.parse(s);
        } catch (ParseException ex) {
            throw new RuntimeException(ex);
        }
    }

    public static <T> Set<T> set(T... elements) {
        HashSet<T> S = new HashSet<T>();
        for (T x : elements)
            S.add(x);
        return S;
    }
}

Related

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