Java Date Parse getDateFromISOString(String iso)

Here you can find the source of getDateFromISOString(String iso)

Description

get Date From ISO String

License

Open Source License

Parameter

Parameter Description
iso -

Return

-

Declaration

@SuppressWarnings("nls")
public static Date getDateFromISOString(String iso) 

Method Source Code


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

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

public class Main {
    /**/*  www  .  ja v a 2 s. c o m*/
     * 
     */
    public static final String ISO_8601_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";

    /**
     * @param iso -
     * @return -
     */
    @SuppressWarnings("nls")
    public static Date getDateFromISOString(String iso) {
        SimpleDateFormat sdf = new SimpleDateFormat(ISO_8601_FORMAT);
        sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
        sdf.setLenient(false);
        try {
            if (iso == null)
                return null;
            return sdf.parse(iso);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. getDateFromIRODSValue(final String irodsValue)
  2. getDateFromISO8601(Object iso8601)
  3. getDateFromISO8601(String dateString)
  4. getDateFromISO8601(String iso8601Date)
  5. getDateFromIsoString(String dateString)
  6. getDateFromOffset(Date prevDate, int offset)
  7. getDateFromOriDateStr(String strDate)
  8. getDateFromRange(String date)
  9. getDateFromRequestStringDate(String dateString)