Java Date ISO Parse parseIsoDate(final String isoDateString)

Here you can find the source of parseIsoDate(final String isoDateString)

Description

Format yyyy-mm-dd

License

Open Source License

Parameter

Parameter Description
isoDateString a parameter

Return

Parsed date or null if a parse error occurs.

Declaration

public static Date parseIsoDate(final String isoDateString) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.TimeZone;

public class Main {
    /**//w w  w  .ja  v  a  2  s.  co m
     * Format yyyy-mm-dd
     * 
     * @param isoDateString
     * @return Parsed date or null if a parse error occurs.
     */
    public static Date parseIsoDate(final String isoDateString) {
        return parseIsoDate(isoDateString, TimeZone.getDefault());
    }

    /**
     * Format yyyy-mm-dd
     * 
     * @param isoDateString
     * @return Parsed date or null if a parse error occurs.
     */
    public static Date parseIsoDate(final String isoDateString, final TimeZone timeZone) {
        final DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        df.setTimeZone(timeZone);
        Date date;
        try {
            date = df.parse(isoDateString);
        } catch (final ParseException ex) {
            return null;
        }
        return date;
    }
}

Related

  1. parseIso8601DateTimeOrDate(String datestr)
  2. parseISO8601String(String dateString)
  3. parseISO8601TimeAndDateString(String dateString)
  4. parseIso8601TimeStamp(String dateString)
  5. parseIsoDate(@Nonnull String asString)
  6. parseIsoDate(final String string)
  7. parseISODate(String date)
  8. parseISODate(String date)
  9. parseIsoDate(String str)