Java Parse Date Pattern YYYY parsemm(String dateStr)

Here you can find the source of parsemm(String dateStr)

Description

yyyy-MM-dd HH:mm

License

Apache License

Parameter

Parameter Description
dateStr a parameter

Exception

Parameter Description
ParseException an exception

Declaration

public static Date parsemm(String dateStr) throws ParseException 

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 final static ThreadLocal<SimpleDateFormat> YYYY_MM_DD_HH_MM_FORMAT = new ThreadLocal<SimpleDateFormat>() {
        @Override/*from  w ww.  ja v a 2 s.c om*/
        protected SimpleDateFormat initialValue() {
            return new SimpleDateFormat("yyyy-MM-dd HH:mm");
        }

        ;
    };
    private final static ThreadLocal<SimpleDateFormat> YYYY_MM_FORMAT = new ThreadLocal<SimpleDateFormat>() {
        @Override
        protected SimpleDateFormat initialValue() {
            return new SimpleDateFormat("yyyy-MM");
        }

        ;
    };

    /**
     * yyyy-MM-dd HH:mm
     *
     * @param dateStr
     * @return
     * @throws ParseException
     */
    public static Date parsemm(String dateStr) throws ParseException {
        return YYYY_MM_DD_HH_MM_FORMAT.get().parse(dateStr);
    }

    public static Date parseMM(String dateStr) throws ParseException {
        return YYYY_MM_FORMAT.get().parse(dateStr);
    }
}

Related

  1. parseHeaderDate(String headerValue)
  2. parseHHMMSS(long time)
  3. parseInsituFileNameDateFormat(String timeString)
  4. parseLastModifDate(final File file)
  5. parseLogstashDate(final String date_string)
  6. parseMysql(String s)
  7. parseMysqlDate(String dateStr)
  8. parseMySQLDateString(String s)
  9. parseMySQLDateTime(String date)