rfc3339

Output RFC 3339 Timestamp in Java

谁说胖子不能爱 提交于 2019-11-30 05:38:49
I want to output a timestamp with a PST offset (e.g., 2008-11-13T13:23:30-08:00). java.util.SimpleDateFormat does not seem to output timezone offsets in the hour:minute format, it excludes the colon. Is there a simple way to get that timestamp in Java? // I want 2008-11-13T12:23:30-08:00 String timestamp = new SimpleDateFormat("yyyy-MM-dd'T'h:m:ssZ").format(new Date()); System.out.println(timestamp); // prints "2008-11-13T12:23:30-0800" See the difference? Also, SimpleDateFormat cannot properly parse the example above. It throws a ParseException . // Throws a ParseException new

Converting ISO 8601 date time to seconds in Python

筅森魡賤 提交于 2019-11-29 11:50:37
问题 I am trying to add two times together. The ISO 8601 time stamp is '1984-06-02T19:05:00.000Z', and I would like to convert it to seconds. I tried using the Python module iso8601, but it is only a parser. Any suggestions? 回答1: If you want to get the seconds since epoch, you can use python-dateutil to convert it to a datetime object and then convert it so seconds using the strftime method. Like so: >>> import dateutil.parser as dp >>> t = '1984-06-02T19:05:00.000Z' >>> parsed_t = dp.parse(t) >>>

How do I parse RFC 3339 datetimes with Java?

别说谁变了你拦得住时间么 提交于 2019-11-28 19:16:19
I'm trying to parse the date returned as a value from the HTML5 datetime input field. Try it in Opera to see an example. The date returned looks like this: 2011-05-03T11:58:01Z . I'd like to parse that into a Java Date or Calendar Object. Ideally a solution should have the following things: No external libraries (jars) Handles all acceptable RFC 3339 formats A String should be able to be easily validated to see if it is a valid RFC 3339 date Just found that google implemented Rfc3339 parser in Google HTTP Client Library https://github.com/google/google-http-java-client/blob/dev/google-http

How to convert Python's .isoformat() string back into datetime object [duplicate]

霸气de小男生 提交于 2019-11-28 17:42:19
This question already has an answer here: Convert timestamps with offset to datetime obj using strptime 4 answers How do I parse an ISO 8601-formatted date? 25 answers So in Python 3, you can generate an ISO 8601 date with .isoformat(), but you can't convert a string created by isoformat() back into a datetime object because Python's own datetime directives don't match properly. That is, %z = 0500 instead of 05:00 (which is produced by .isoformat()). For example: >>> strDate = d.isoformat() >>> strDate '2015-02-04T20:55:08.914461+00:00' >>> objDate = datetime.strptime(strDate,"%Y-%m-%dT%H:%M:

Parse rfc3339 date strings in Python? [duplicate]

北城以北 提交于 2019-11-28 04:15:12
This question already has an answer here: How do I parse an ISO 8601-formatted date? 25 answers I have a datasets where all the dates have the following format: 2012-10-09T19:00:55Z I'd like to be able to be able to use methods like .weekday on them. How do I convert them to the proper format in Python? You can use dateutil.parser.parse to parse strings into datetime objects. dateutil.parser.parse will attempt to guess the format of your string, if you know the exact format in advance then you can use datetime.strptime which you supply a format string to (see Brent Washburne's answer). from

Convert an RFC 3339 time to a standard Python timestamp

喜你入骨 提交于 2019-11-27 20:38:58
Is there an easy way to convert an RFC 3339 time into a regular Python timestamp? I've got a script which is reading an ATOM feed and I'd like to be able to compare the timestamp of an item in the ATOM feed to the modification time of a file. I notice from the ATOM spec , that ATOM dates include a time zone offset ( Z<a number> ) but, in my case, there's nothing after the Z so I guess we can assume GMT. I suppose I could parse the time with a regex of some sort but I was hoping Python had a built-in way of doing it that I just haven't been able to find. No builtin, afaik. feed.date.rfc3339

Generate an RFC 3339 timestamp similar to Google Tasks API?

旧城冷巷雨未停 提交于 2019-11-27 19:22:14
I am in the process of building an app that syncs with Google Tasks. As part part of the syncing, I want to compare the local task and the API task, and see which one has been changed more recently. Each task from Google's API contains an updated property, which looks like this: 2011-08-30T13:22:53.108Z Now I would like to generate a timestamp similar to that, so that every time I update a task on my app it sets a new updated value. To generate the RFC 3339 timestamp I am using - http://cbas.pandion.im/2009/10/generating-rfc-3339-timestamps-in.html which generates something like this: 2011-08

Generate an RFC 3339 timestamp similar to Google Tasks API?

家住魔仙堡 提交于 2019-11-27 19:09:07
问题 I am in the process of building an app that syncs with Google Tasks. As part part of the syncing, I want to compare the local task and the API task, and see which one has been changed more recently. Each task from Google's API contains an updated property, which looks like this: 2011-08-30T13:22:53.108Z Now I would like to generate a timestamp similar to that, so that every time I update a task on my app it sets a new updated value. To generate the RFC 3339 timestamp I am using - http://cbas

How do I parse and convert a DateTime to the RFC 3339 date-time format?

扶醉桌前 提交于 2019-11-27 12:34:10
How do I convert a DateTime structure to its equivalent RFC 3339 formatted string representation and/or parse this string representation back to a DateTime structure? The RFC-3339 date-time format is used in a number of specifications such as the Atom Syndication Format . Matt Howells You don't need to write your own conversion code. Just use XmlConvert.ToDateTime(string s, XmlDateTimeSerializationMode dateTimeOption) to parse a RFC-3339 string, and XmlConvert.ToString(DateTime value, XmlDateTimeSerializationMode dateTimeOption) to convert a (UTC) datetime to a string. Ref. http://msdn

How do I parse RFC 3339 datetimes with Java?

帅比萌擦擦* 提交于 2019-11-27 11:36:30
问题 I'm trying to parse the date returned as a value from the HTML5 datetime input field. Try it in Opera to see an example. The date returned looks like this: 2011-05-03T11:58:01Z . I'd like to parse that into a Java Date or Calendar Object. Ideally a solution should have the following things: No external libraries (jars) Handles all acceptable RFC 3339 formats A String should be able to be easily validated to see if it is a valid RFC 3339 date 回答1: Just found that google implemented Rfc3339