Here you can find the source of parseNoSecondFormat(String sDate)
Parameter | Description |
---|---|
sDate | a parameter |
Parameter | Description |
---|---|
ParseException | an exception |
public static Date parseNoSecondFormat(String sDate) throws ParseException
//package com.java2s; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public final static String noSecondFormat = "yyyy-MM-dd HH:mm"; /**//from ww w. j a va2 s. co m * yyyy-MM-dd HH:mm * * @param sDate * @return * @throws ParseException */ public static Date parseNoSecondFormat(String sDate) throws ParseException { DateFormat dateFormat = new SimpleDateFormat(noSecondFormat); if ((sDate == null) || (sDate.length() < noSecondFormat.length())) { throw new ParseException("length too little", 0); } return dateFormat.parse(sDate); } }