Java Parse Date Pattern YYYY parse(String s, String formatPattern)

Here you can find the source of parse(String s, String formatPattern)

Description

parse

License

Apache License

Declaration

public static Date parse(String s, String formatPattern) 

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 {
    private static final String LEGACY_FORMAT = "MM/dd/yyyy HH:mm aa";

    public static Date parse(String s, String formatPattern) {
        try {/*from   w  w  w .  java 2 s. c  om*/
            return new SimpleDateFormat(formatPattern).parse(s);
        } catch (ParseException e) {
            throw new RuntimeException("could not parse date: " + s + " LEGACY_FORMAT = "
                    + new SimpleDateFormat(LEGACY_FORMAT).toPattern(), e);
        }
    }
}

Related

  1. parse(String s)
  2. parse(String s)
  3. parse(String s)
  4. parse(String s)
  5. parse(String s)
  6. parse(String source)
  7. parse(String source)
  8. parse(String source)
  9. parse(String source, Date defaultValue)