iso8601

How do I convert 2010-12-15T16:26:49.841-08:00 to a GregorianCalendar in Java? [duplicate]

拥有回忆 提交于 2019-12-01 14:04:13
This question already has an answer here: Converting ISO 8601-compliant String to java.util.Date 27 answers I have a string date "2010-12-15T16:26:49.841-08:00" and I need to convert it to a GregorianCalendar in Java. How do you do this? Solution from Jesper's answer Code for the solution using joda time: DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ").withOffsetParsed(); DateTime date = formatter.parseDateTime("2010-12-15T16:26:49.841-08:00"); Unfortunately, the standard SimpleDateFormat class cannot handle ISO 8601 format very well. Specifically, it

Getting the number equalent of duration using GAS

半城伤御伤魂 提交于 2019-12-01 11:39:00
问题 I have a cell that has the value of type duration, I have set the value to 00:10:00 which is 10 minutes, When I change the format of the cell to number it will show 0.01. How will I get programmically using apps script the decimal equivalent of using apps script code? 00:10:00 is 0.01 10:00:00 is 0.42 What is the calculation used to convert this duration string? 回答1: How about this answer? Values of 0.01 and 0.42 are the serial number. But in this case, when each cell is seen, 0.01 and 0.42

Epoch or iso8601 date format?

一笑奈何 提交于 2019-12-01 11:13:47
For passing times in JSON to/from a web API, why would I choose to use an ISO8601 string instead of simply the UTC epoch value? For example, both of these are the same: Epoch = 1511324473 iso8601 = 2017-11-22T04:21:13Z The epoch value is obviously shorter in length, which is always good for mobile data usage, and it's pretty simple to convert between epoch values and the language's local Date type variable. I'm just not seeing the benefit to using an ISO string value. Both are unambiguous and easy to parse in programs. The benefit of epoch like you have mentioned is that it is smaller and will

How to convert ISO 8601 date (string) to Date?

[亡魂溺海] 提交于 2019-12-01 10:52:44
I am parsing XML file. In this file there is one tag containing date string "2008-11-10T05:51:33Z" and I want convert this string in to java.util.Date object. How can this be done? Use java.text.DateFormat - or more likely, SimpleDateFormat . Alternatively, go for Joda Time with its infinitely better API. Be careful with the Java built-in APIs - DateFormats aren't thread-safe. (They are in Joda Time, which uses immutable types almost everywhere.) An (untested - should be fine except for possibly the timezone bit) example for the Joda Time API: DateTimeFormatter fmt = DateTimeFormat.forPattern(

R - UTC to LOCAL time given Olson timezones

独自空忆成欢 提交于 2019-12-01 10:35:16
I have time series data from 1974-2013 with a column for datetimeUTC (YYYY-MM-DD hh:mm +0000), and a column for the timezones in Olson format (e.g., Canada/Pacific, Canada/Eastern). I can convert the whole UTCdatetime column to a common timezone like this: dataset$datetimeEST <- strptime( dataset$datetimeUTC, format="%Y-%m-%d %H:%M:%S%z", tz="Canada/Eastern" ) How do I convert datetimeUTC to datetimeLOCAL , given the corresponding timezone in each row? Let me back up a bit. I have data from across the country (6 timezones) formatted in ISO8601 representation for 1974-2013. The timestamps are

Use ISO-8601 dates in JAX-RS responses

 ̄綄美尐妖づ 提交于 2019-12-01 10:23:39
问题 I'm building RESTful web services using Java EE 7 on GlassFish 4. When serializing POJOs containing java.util.Date objects, the timezone information is not included. How can I customize object serialization so java.util.Date s have timezone info included? For example, instead of this: { "id": 1234, "foo": "2014-05-19T13:53:49.392" } I'd instead like this: { "id": 1234, "foo": "2014-05-19T13:53:49.392+09:30" } Where the server's timezone is GMT + 09:30. 回答1: This is caused by a bug in MOXy,

R - UTC to LOCAL time given Olson timezones

試著忘記壹切 提交于 2019-12-01 08:30:34
问题 I have time series data from 1974-2013 with a column for datetimeUTC (YYYY-MM-DD hh:mm +0000), and a column for the timezones in Olson format (e.g., Canada/Pacific, Canada/Eastern). I can convert the whole UTCdatetime column to a common timezone like this: dataset$datetimeEST <- strptime( dataset$datetimeUTC, format="%Y-%m-%d %H:%M:%S%z", tz="Canada/Eastern" ) How do I convert datetimeUTC to datetimeLOCAL , given the corresponding timezone in each row? Let me back up a bit. I have data from

Epoch or iso8601 date format?

我只是一个虾纸丫 提交于 2019-12-01 06:29:21
问题 For passing times in JSON to/from a web API, why would I choose to use an ISO8601 string instead of simply the UTC epoch value? For example, both of these are the same: Epoch = 1511324473 iso8601 = 2017-11-22T04:21:13Z The epoch value is obviously shorter in length, which is always good for mobile data usage, and it's pretty simple to convert between epoch values and the language's local Date type variable. I'm just not seeing the benefit to using an ISO string value. 回答1: Both are

Format DateInterval as ISO8601

你说的曾经没有我的故事 提交于 2019-12-01 04:33:52
问题 I am currently working on a php project and need to format a DateInterval as ISO8601 (something like this): P5D This format can be used to create DateTime and DateInterval objects, but I can't figure out a way to format a DateInterval into this format. Is there any? If not, what might be a lightweight solution to that? 回答1: Well, if you look at the spec for the format when you construct one: Y years M months D days W weeks. These get converted into days, so can not be combined with D. H hours

Convert ISO 8601 duration with JavaScript

喜你入骨 提交于 2019-11-30 23:50:19
问题 How can I convert duration with JavaScript, for example: PT16H30M 回答1: You could theoretically get an ISO8601 Duration that looks like the following: P1Y4M3W2DT10H31M3.452S I wrote the following regular expression to parse this into groups: (-)?P(?:([.,\d]+)Y)?(?:([.,\d]+)M)?(?:([.,\d]+)W)?(?:([.,\d]+)D)?T(?:([.,\d]+)H)?(?:([.,\d]+)M)?(?:([.,\d]+)S)? It's not pretty, and someone better versed in regular expressions might be able to write a better one. The groups boil down into the following: