date-parsing

Convert UTC to local time with NSDateFormatter

送分小仙女□ 提交于 2019-11-26 22:47:01
问题 I am getting the following string from a server in my iOS app: 20140621-061250 How can I convert it to the local time? How can I define my date formatter? Is this correct? dateFormatter.dateFormat = @"YYYYMMd-HHmmss"; 回答1: The question doesn't specify the nature of what you mean by converting, exactly, but the first thing you should do, regardless of the final goal, is to correctly parse the server response using a properly configured NSDateFormatter . This requires specification of the

Parse Date String to Some Java Object

大兔子大兔子 提交于 2019-11-26 20:57:48
I am working in a project that reads files and processes data. There I got to work with dates for example: 2012-01-10 23:13:26 January 13, 2012 I found the package Joda, kinda interesting package but don't know if it is the easiest around. I was able to parse the first example to a DateTime object (Joda) reg-ex and String manipulation. (Ex: by replacing the space by '-' and passing it to constructor. new DateTime("2012-01-10 23:13:26".replace(' ', '-')) I guess it worked, but the problem is with the second format. How can I use such an input to extract a an object, preferably a Joda object. I

Problem with date formats in JavaScript with different browsers

倖福魔咒の 提交于 2019-11-26 20:43:54
I am working with dates in an RSS feed, but am finding differing results when using the code below in IE, Chrome and Firefox: new Date('2001-01-01T12:00:00Z') Firefox is happy with that, but Chrome and IE return Invalid Date. I thought I'd try replacing the T and Z as follows: new Date('2001-01-01 12:00:00') This time Chrome is happy with that, but Firefox and IE return Invalid Date. Any ideas what I should do to get a date object in all browsers with this format?! Many thanks, Tim This works in all browsers on my box - try it in the console: alert(new Date('2001/01/31 12:00:00')) so new Date(

How to convert a date in this format (Tue Jul 13 00:00:00 CEST 2010) to a Java Date (The string comes from an alfresco property)

若如初见. 提交于 2019-11-26 12:44:50
问题 i\'m managing a date that comes from an Alfresco Properties and is in the specified (Tue Jul 13 00:00:00 CEST 2010) and i need to convert it to a Java date...i\'ve looked around and found millions of posts for various string to date conversion form and also this page and so i tried something like this: private static final DateFormat alfrescoDateFormat = new SimpleDateFormat(\"EEE MMM dd HH:mm:ss zzz yyyy\"); Date dataRispostaDate = alfrescoDateFormat.parse(dataRisposta); But it throws an

format date with moment.js

北城以北 提交于 2019-11-26 12:35:36
问题 I have a string in this format: var testDate = \"Fri Apr 12 2013 19:08:55 GMT-0500 (CDT)\" I would like to using moment.js get it in this format mm/dd/yyyy : 04/12/2013 for display. I tried to do it using this method, moment(testDate,\'mm/dd/yyyy\'); Which errors and says there is no such method called replace ? am i approaching this in the wrong way? Edit: I should also mention that i am using a pre packaged version of moment.js, packaged for meteor.js Object [object Date] has no method \

Parsing a date’s ordinal indicator ( st, nd, rd, th ) in a date-time string

醉酒当歌 提交于 2019-11-26 11:55:38
I checked the SimpleDateFormat javadoc , but I am not able to find a way to parse the ordinal indicator in a date format like this: Feb 13th 2015 9:00AM I tried "MMM dd yyyy hh:mma" , but the days have to be in number for it to be correct? Is it possible to parse the "13th" date using a SimpleDateFormat without having to truncate the string? Java's SimpleDateFormat doesn't support an ordinal suffix, but the ordinal suffix is just eye candy - it is redundant and can easily be removed to allow a straightforward parse: Date date = new SimpleDateFormat("MMM dd yyyy hh:mma") .parse(str.replaceAll("

String-Date conversion with nanoseconds

老子叫甜甜 提交于 2019-11-26 11:14:38
问题 I\'ve been struggling for a while with this piece of code for an Android app and I can\'t get the hang of it. I\'ve read and tried every solution I found on stackoverflow and other places, but still no luck. What I want to do is have a function to convert a string like \"17.08.2012 05:35:19:7600000\" to a UTC date and a function that takes an UTC date and converts it to a string like that. String value = \"17.08.2012 05:35:19:7600000\"; DateFormat df = new SimpleDateFormat(\"dd.MM.yyyy HH:mm

How to parse a date string into a c++11 std::chrono time_point or similar?

偶尔善良 提交于 2019-11-26 09:28:20
问题 Consider a historic date string of format: Thu Jan 9 12:35:34 2014 I want to parse such a string into some kind of C++ date representation, then calculate the amount of time that has passed since then. From the resulting duration I need access to the numbers of seconds, minutes, hours and days. Can this be done with the new C++11 std::chrono namespace? If not, how should I go about this today? I\'m using g++-4.8.1 though presumably an answer should just target the C++11 spec. 回答1: std::tm tm

Parse Date String to Some Java Object

怎甘沉沦 提交于 2019-11-26 08:34:44
问题 I am working in a project that reads files and processes data. There I got to work with dates for example: 2012-01-10 23:13:26 January 13, 2012 I found the package Joda, kinda interesting package but don\'t know if it is the easiest around. I was able to parse the first example to a DateTime object (Joda) reg-ex and String manipulation. (Ex: by replacing the space by \'-\' and passing it to constructor. new DateTime(\"2012-01-10 23:13:26\".replace(\' \', \'-\')) I guess it worked, but the

Parsing of Ordered Timestamps in Local Time (to UTC) While Observing Daylight Saving Time

别等时光非礼了梦想. 提交于 2019-11-26 06:48:54
问题 I have CSV data files with timestamped records that are in local time. Unfortunately the data files cover the period where daylight saving time changes (Nov 3rd 2013) so the time component of the timestamps for the records go: 12:45, 1:00, 1:15, 1:30, 1:45, 1:00, 1:15, 1:30, 1:45, 2:00 . I want to be able to convert and store the values in the database as UTC. Unfortunately the standard DateTime.Parse() function of .NET will parse as this (all November 3rd 2013): | Time String | Parsed Local