Java Date ISO Parse parseISO(String input)

Here you can find the source of parseISO(String input)

Description

parse ISO

License

Apache License

Declaration

public static Date parseISO(String input) throws java.text.ParseException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static Date parseISO(String input) throws java.text.ParseException {

        // NOTE: SimpleDateFormat uses GMT[-+]hh:mm for the TZ which breaks
        // things a bit. Before we go on we have to repair this.
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz");

        // this is zero time so we need to add that TZ indicator for
        if (input.endsWith("Z")) {
            input = input.substring(0, input.length() - 1) + "GMT-00:00";
        } else {/*from   ww w  .j  a v a  2 s .c  o m*/
            int inset = 6;

            String s0 = input.substring(0, input.length() - inset);
            String s1 = input.substring(input.length() - inset, input.length());

            input = s0 + "GMT" + s1;
        }

        return df.parse(input);

    }
}

Related

  1. parseDateISO(String value)
  2. parseDateISO(String value)
  3. parseDateTime(String iso8061StrDateTime)
  4. parseFromIso8601(String s)
  5. parseISO(String aIsoString)
  6. parseISO(String strValue)
  7. parseIso8601(String iso8601String)
  8. parseIso8601(String rawstr)
  9. parseIso8601(String time)