Java Date ISO Parse parseTimestampIso8601(String timestamp)

Here you can find the source of parseTimestampIso8601(String timestamp)

Description

Parses the specified timestamp in the ISO 8601 (RFC 3339) format (e.g.

License

MIT License

Parameter

Parameter Description
timestamp a timestamp as a string.

Exception

Parameter Description
ParseException if the timestamp cannot be parsed.

Return

the calendar representation of the specified timestamp.

Declaration

public static Date parseTimestampIso8601(String timestamp) throws ParseException 

Method Source Code

//package com.java2s;
/*/*  w w  w  .j  a va  2s  . c  om*/
 * Copyright (c) 2015-2016 QuartzDesk.com.
 * Licensed under the MIT license (https://opensource.org/licenses/MIT).
 */

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

import java.util.Date;

import java.util.Locale;

import java.util.TimeZone;

public class Main {
    /**
     * Format for ISO 8601 (RFC 3339) date string -- "2012-06-27T12:31:00.003+0000".
     */
    private static final String TIMESTAMP_FORMAT_ISO8601 = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";

    /**
     * Parses the specified timestamp in the ISO 8601 (RFC 3339) format
     * (e.g. "2012-06-27T12:31:00.003+0000").
     *
     * @param timestamp a timestamp as a string.
     * @return the calendar representation of the specified timestamp.
     * @throws ParseException if the timestamp cannot be parsed.
     */
    public static Date parseTimestampIso8601(String timestamp) throws ParseException {
        SimpleDateFormat f = new SimpleDateFormat(TIMESTAMP_FORMAT_ISO8601, Locale.US);
        f.setTimeZone(TimeZone.getDefault());
        return f.parse(timestamp);
    }
}

Related

  1. parseIsoDateAndTimeString(String aDateString, String aTimeString)
  2. parseIsoDateInput(String str)
  3. parseIsoDateTime(String isoDateTime)
  4. parseISODuration(String duration)
  5. parseIsoString(String time)
  6. strongCheckIso8601Date(String date)
  7. time2StringISO(Date date)
  8. timestampAsIsoString(long timestamp)
  9. toCalendar(final String iso8601string)