Java Date ISO Parse parseIsoDate(@Nonnull String asString)

Here you can find the source of parseIsoDate(@Nonnull String asString)

Description

parse Iso Date

License

Mozilla Public License

Declaration

@Nonnull
    public static Date parseIsoDate(@Nonnull String asString) throws IllegalArgumentException 

Method Source Code

//package com.java2s;
/*****************************************************************************************
 * *** BEGIN LICENSE BLOCK *****//from  w  w  w. jav  a  2 s . c  o  m
 *
 * Version: MPL 2.0
 *
 * echocat Jomon, Copyright (c) 2012-2013 echocat
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * *** END LICENSE BLOCK *****
 ****************************************************************************************/

import javax.annotation.Nonnull;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public static final String ISO_PATTERN = "yyyy-MM-dd'T'HH:mm:ssZ";

    @Nonnull
    public static Date parseIsoDate(@Nonnull String asString) throws IllegalArgumentException {
        try {
            return new SimpleDateFormat(ISO_PATTERN).parse(asString);
        } catch (final ParseException e) {
            throw new IllegalArgumentException(
                    "Could not parse: " + asString + ", it does not match pattern: " + ISO_PATTERN, e);
        }
    }
}

Related

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