Java Date ISO Parse iso8601(String date)

Here you can find the source of iso8601(String date)

Description

iso

License

Open Source License

Declaration

public static Date iso8601(String date) 

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 {
    public static Date iso8601(String date) {
        try {//w w w  . ja  v  a2s  .  com
            return newDateFormat().parse(date);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
    }

    public static String iso8601(Date date) {
        return newDateFormat().format(date);
    }

    private static DateFormat newDateFormat() {
        DateFormat dateFormat = new SimpleDateFormat(
                "yyyy-MM-dd'T'HH:mm:ss'Z'");
        dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        return dateFormat;
    }
}

Related

  1. getCalendarFromISO8601String(final String timestamp, final TimeZone tz)
  2. getISODate(String date)
  3. getISODateInSeconds(String isoDate)
  4. getIsoStringDate(Date date)
  5. getISOStringFromDate(long time)
  6. iso86012date(String s)
  7. iso8601ToCalendar(String s)
  8. iso8601ToDate(String s)
  9. ISO8601ToSeconds(String iso8601)