Java Second Format parseNoSecondFormat(String sDate)

Here you can find the source of parseNoSecondFormat(String sDate)

Description

yyyy-MM-dd HH:mm

License

Open Source License

Parameter

Parameter Description
sDate a parameter

Exception

Parameter Description
ParseException an exception

Declaration

public static Date parseNoSecondFormat(String sDate) throws ParseException 

Method Source Code


//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);
    }
}

Related

  1. getThisSecondTime()
  2. getTimeSecondInteger(Date date)
  3. getToSecond()
  4. humanDateToSeconds(String date)
  5. parseLongToString(long millsSeconds)
  6. printElapsedSeconds(long start)
  7. removeSecondsFromDateString(String sdate)
  8. Second2DateString(int v)
  9. secondsBetween(String from, String to, String format)