Here you can find the source of parseTimestampIso8601(String timestamp)
Parameter | Description |
---|---|
timestamp | a timestamp as a string. |
Parameter | Description |
---|---|
ParseException | if the timestamp cannot be parsed. |
public static Date parseTimestampIso8601(String timestamp) throws ParseException
//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); } }