Java Date ISO Parse ISO8601ToSeconds(String iso8601)

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

Description

Converts an ISO8601 timestamp into a RBNB timestamp.

License

Open Source License

Parameter

Parameter Description
iso8601 an IS8601 timestamp

Exception

Parameter Description
ParseExceptionif the timestamp is not valid

Return

a RBNB timestamp

Declaration

public static double ISO8601ToSeconds(String iso8601)
        throws ParseException 

Method Source Code

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

import java.text.ParseException;
import java.text.SimpleDateFormat;

public class Main {
    /**/*w ww  . j a  v  a2s .  com*/
     * A date format for IS8601 date and time representation. This representation
     * is to the millisecond in UTC time.
     */
    private static final SimpleDateFormat ISO8601_DATE_FORMAT = new SimpleDateFormat(
            "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");

    /**
     * Converts an ISO8601 timestamp into a RBNB timestamp.
     * 
     * @param iso8601          an IS8601 timestamp
     * @return                 a RBNB timestamp
     * @throws ParseException  if the timestamp is not valid
     */
    public static double ISO8601ToSeconds(String iso8601)
            throws ParseException {
        return ISO8601_DATE_FORMAT.parse(iso8601).getTime() / 1000d;
    }
}

Related

  1. getISOStringFromDate(long time)
  2. iso8601(String date)
  3. iso86012date(String s)
  4. iso8601ToCalendar(String s)
  5. iso8601ToDate(String s)
  6. isoDateStringToDate(String dateString)
  7. isOneOf(String value, String... values)
  8. ISOToJulianDate(String dateObs)
  9. isValidISO8601(String time)