Illegal pattern character ‘T’ when parsing a date string to java.util.Date

I have a date string and I want to parse it to normal date use the java Date API,the following is my code: public static void main(String[] args) { String date=”2010-10-02T12:23:23Z”; String pattern=”yyyy-MM-ddThh:mm:ssZ”; SimpleDateFormat sdf=new SimpleDateFormat(pattern); try { Date d=sdf.parse(date); System.out.println(d.getYear()); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } However … Read more

Python UTC datetime object’s ISO format doesn’t include Z (Zulu or Zero offset)

Why python 2.7 doesn’t include Z character (Zulu or zero offset) at the end of UTC datetime object’s isoformat string unlike JavaScript? >>> datetime.datetime.utcnow().isoformat() ‘2013-10-29T09:14:03.895210′ Whereas in javascript >>> console.log(new Date().toISOString()); 2013-10-29T09:38:41.341Z Best Answers Python datetime objects don’t have time zone info by default, and without it, Python actually violates the ISO 8601 specification (if no time … Read more

How can I parse / create a date time stamp formatted with fractional seconds UTC timezone (ISO 8601, RFC 3339) in Swift?

How to generate a date time stamp, using the format standards for ISO 8601 and RFC 3339? The goal is a string that looks like this: “2015-01-01T00:00:00.000Z” Format: year, month, day, as “XXXX-XX-XX” the letter “T” as a separator hour, minute, seconds, milliseconds, as “XX:XX:XX.XXX”. the letter “Z” as a zone designator for zero offset, … Read more

How do I format a date as ISO 8601 in moment.js?

This docs mention moment.ISO_8601 as a formatting option (from 2.7.0 – http://momentjs.com/docs/#/parsing/special-formats/), but neither of these work (even 2.7.0): var date = moment(); date.format(moment.ISO_8601); // error moment.format(date, moment.ISO_8601); // error (http://jsfiddle.net/b3d6uy05/1/) How can I get an ISO 8601 from moment.js? 9 Answers 9

How do I output an ISO 8601 formatted string in JavaScript?

I have a Date object. How do I render the title portion of the following snippet? <abbr title=”2010-04-02T14:12:07″>A couple days ago</abbr> I have the “relative time in words” portion from another library. I’ve tried the following: function isoDate(msSinceEpoch) { var d = new Date(msSinceEpoch); return d.getUTCFullYear() + ‘-‘ + (d.getUTCMonth() + 1) + ‘-‘ + … Read more

How do I translate an ISO 8601 datetime string into a Python datetime object? [duplicate]

This question already has answers here: How do I parse an ISO 8601-formatted date? (28 answers) Closed 7 years ago. I’m getting a datetime string in a format like “2009-05-28T16:15:00” (this is ISO 8601, I believe). One hackish option seems to be to parse the string using time.strptime and passing the first six elements of … Read more

Converting ISO 8601-compliant String to java.util.Date

I am trying to convert an ISO 8601 formatted String to a java.util.Date. I found the pattern yyyy-MM-dd’T’HH:mm:ssZ to be ISO8601-compliant if used with a Locale (compare sample). However, using the java.text.SimpleDateFormat, I cannot convert the correctly formatted String 2010-01-01T12:00:00+01:00. I have to convert it first to 2010-01-01T12:00:00+0100, without the colon. So, the current solution … Read more

How do I parse an ISO 8601-formatted date?

I need to parse RFC 3339 strings like “2008-09-03T20:56:35.450686Z” into Python’s datetime type. I have found strptime in the Python standard library, but it is not very convenient. What is the best way to do this? 28 s 28 The datetime standard library has, since Python 3.7, a function for inverting datetime.isoformat(). classmethod datetime.fromisoformat(date_string): Return … Read more