Java Parse Date Pattern YYYY parseWsDate(String date)

Here you can find the source of parseWsDate(String date)

Description

parse Ws Date

License

Open Source License

Declaration

public static Date parseWsDate(String date) throws ParseException 

Method Source Code


//package com.java2s;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.Locale;

public class Main {
    public static final String DATE_FORMAT_D = "EEE, d MMM yyyy HH:mm:ss Z";
    public static final String WS_DATE_FORMAT = "yyyy/MM/dd HH:mm:ss Z";

    public static Date parseWsDate(String date) throws ParseException {
        return parseDate(date, WS_DATE_FORMAT);
    }/*from   www . j a  v a 2s  .  c om*/

    public static Date parseDate(String date, String format) {
        if (date == null) {
            return null;
        }
        date = date.trim();
        if (date.length() == 0) {
            return null;
        }
        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
        try {
            return dateFormat.parse(date);
        } catch (ParseException e) {
            //throw new RuntimeException(e);
            return null;
        }
    }

    public static Date parse(String date) throws ParseException {
        if (date == null) {
            return null;
        }
        date = date.trim();
        if (date.length() == 0) {
            return null;
        }
        SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT_D, Locale.US);
        return format.parse(date);
    }
}

Related

  1. parseVariuosDateTime(String dateStr)
  2. parseW3CDate(String dateString)
  3. parseW3CDateRobust(String dateString)
  4. parseW3CDateTime(String date)
  5. parseW3CDateTime(String sDate, Locale locale)
  6. parseXEP0082Date(String dateString)
  7. parseXsdDate(final Date date)
  8. parseXsdDateTime(String date)
  9. parseYmd(String date)