Here you can find the source of parsemm(String dateStr)
Parameter | Description |
---|---|
dateStr | a parameter |
Parameter | Description |
---|---|
ParseException | an exception |
public static Date parsemm(String dateStr) throws ParseException
//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); } }