Android ISO Format to Date Convert iso8601ToJavaDate(final String strDate)

Here you can find the source of iso8601ToJavaDate(final String strDate)

Description

iso To Java Date

Declaration

public static Date iso8601ToJavaDate(final String strDate) 

Method Source Code

//package com.java2s;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class Main {
    private static final ThreadLocal<DateFormat> ISO8601Format = new ThreadLocal<DateFormat>() {
        @Override/* w w  w .jav a2s. c o m*/
        protected DateFormat initialValue() {
            return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US);
        }
    };

    public static Date iso8601ToJavaDate(final String strDate) {
        try {
            DateFormat formatter = ISO8601Format.get();
            return formatter.parse(strDate);
        } catch (ParseException e) {
            return null;
        }
    }
}

Related

  1. fromIso8601(String date)
  2. isoDateStringToDate(String dateString)
  3. iso8601ToJavaDate(final String strDate)