Java Parse Date parseDateNoTimeWithDelimit(String sDate, String delimit)

Here you can find the source of parseDateNoTimeWithDelimit(String sDate, String delimit)

Description

parse Date No Time With Delimit

License

Open Source License

Declaration

public static Date parseDateNoTimeWithDelimit(String sDate, String delimit) 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 shortFormat = "yyyyMMdd";

    public static Date parseDateNoTimeWithDelimit(String sDate, String delimit) throws ParseException {
        sDate = sDate.replaceAll(delimit, "");

        DateFormat dateFormat = new SimpleDateFormat(shortFormat);

        if ((sDate == null) || (sDate.length() != shortFormat.length())) {
            throw new ParseException("length not match", 0);
        }/*from   w w  w . ja v a 2s. c  om*/

        return dateFormat.parse(sDate);
    }
}

Related

  1. parseDateList(List dateList)
  2. parseDateLong(String date, Locale locale)
  3. parseDateLongFormat(String sDate)
  4. parseDateLoose(String dateString)
  5. parseDateNewFormat(String sDate)
  6. parseDateOrTimeString(String aDateString, String aFormatString)
  7. parseDateRFC(String value)
  8. parseDateRfc822(String str)
  9. parseDates(String query)