Java Year Parse parse2yyyyMMddHHmmss(String date)

Here you can find the source of parse2yyyyMMddHHmmss(String date)

Description

parseyyyy M Mdd H Hmmss

License

Apache License

Declaration

public static Date parse2yyyyMMddHHmmss(String date) 

Method Source Code

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

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

public class Main {
    private static final String yyyyMMddHHmmss = "yyyyMMddHHmmss";

    public static Date parse2yyyyMMddHHmmss(String date) {
        return parseDate(date, yyyyMMddHHmmss);
    }/*from  ww  w . ja  v a2 s .co m*/

    public static Date parseDate(String date, String pattern) {
        SimpleDateFormat df = new SimpleDateFormat(pattern);
        df.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
        try {
            return df.parse(date);
        } catch (ParseException e) {
            throw new IllegalArgumentException(e);
        }
    }
}

Related

  1. parseDashedDateDDMMYYYY(String date)
  2. parseDateSlashedMmDdYyyy(String dateStr)
  3. parseDateTime_mmddyyyy(String s)
  4. parseDateyyyy_MM_DD2(String ds)