Java Parse Date Pattern YYYY parse(String d)

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

Description

parse

License

Apache License

Declaration

public static Date parse(String d) throws ParseException 

Method Source Code

//package com.java2s;
/**/*from  w  w w  . ja  v a2  s  . c  o  m*/
 * Copyright (C) 2016 - 2017 youtongluan.
 *
 * 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.Date;

public class Main {
    public final static String DATETIME = "yyyy-MM-dd HH:mm:ss";

    public static Date parse(String d, String fromat) throws ParseException {
        if (d == null) {
            return null;
        }
        SimpleDateFormat sf = new SimpleDateFormat(fromat);
        return sf.parse(d);
    }

    public static Date parse(String d) throws ParseException {
        return parse(d, DATETIME);
    }
}

Related

  1. parse(final String source)
  2. parse(Long date)
  3. parse(Long time)
  4. parse(Object object)
  5. parse(String calendarString)
  6. parse(String date)
  7. parse(String date)
  8. parse(String date)
  9. parse(String date)