Java Parse Date Pattern YYYY parse(String datestr)

Here you can find the source of parse(String datestr)

Description

parse

License

Open Source License

Declaration

private static Date parse(String datestr) 

Method Source Code

//package com.java2s;
/*//from w  ww. j a  va2s  . com
 * *************************************************************************************
 *  Copyright (C) 2008 EsperTech, Inc. All rights reserved.                            *
 *  http://esper.codehaus.org                                                          *
 *  http://www.espertech.com                                                           *
 *  ---------------------------------------------------------------------------------- *
 *  The software in this package is published under the terms of the GPL license       *
 *  a copy of which has been included with this distribution in the license.txt file.  *
 * *************************************************************************************
 */

import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS";

    private static Date parse(String datestr) {
        Date date;
        try {
            SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
            date = sdf.parse(datestr);
        } catch (Exception ex) {
            throw new RuntimeException("Error parsing date '" + datestr
                    + "' as format '" + DATE_FORMAT + "' : "
                    + ex.getMessage(), ex);
        }
        return date;
    }
}

Related

  1. parse(String date)
  2. parse(String date)
  3. parse(String date, String format)
  4. parse(String dateAsString)
  5. parse(String DateStr)
  6. parse(String dateStr)
  7. parse(String dateStr)
  8. parse(String dateString)
  9. parse(String dateString)