date-parsing

How can I make a DateTimeFormatter that accepts trailing junk?

橙三吉。 提交于 2020-01-21 06:50:51
问题 I'm retrofitting old some SimpleDateFormat code to use the new Java 8 DateTimeFormatter . SimpleDateFormat , and thus the old code, accepts strings with stuff in them after the date like "20130311nonsense". The DateTimeFormat I created throws a DateTimeParseException for these strings, which is probably the right thing to do, but I'd like to maintain compatibility. Can I modify my DateTimeFormat to accept these strings? I'm currently creating it like this: DateTimeFormatter.ofPattern(

Parsing arbitrary format JSON date with Swift Decodable

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-17 00:27:47
问题 I am attempting to format a date in a JSON document into the format "mm-dd-yyyy". I have the following data: {"data":[{ "id": 123, "url": "https://www.google.com", "title": "The Google link", "created_at": "2017-08-29T04:00:00.000Z",//date to format "sent": true, "alternative": "https://google.com", "things": [], "description": [ "search", "lookup" ], "company": "Alphabet" }]} This is my struct: struct Sitedata: Decodable{ let data: [site] } struct site: Decodable { let id: Int let url:

Convert a formatted date string to a date value in XPath

 ̄綄美尐妖づ 提交于 2020-01-15 03:13:48
问题 How can I convert a date contained in a string into a date value with XPath? I got the string by formatting a date value with fn:format-date , and now I want the date value from the formatted string. Thank you, 回答1: You can use EXSLT's date:date(string) . It is implemented in most XSLT processors but also as a pure XSLT function. Documentation: http://www.exslt.org/date/functions/date/index.html. 来源: https://stackoverflow.com/questions/9208959/convert-a-formatted-date-string-to-a-date-value

Convert month name to number in Delphi?

孤街浪徒 提交于 2019-12-29 09:17:20
问题 Is there some built-in Delphi (XE2)/Windows method to convert month names to numbers 1-12; instead of looping through (TFormatSettings.)LongMonthNames[] myself? 回答1: You can use IndexStr from StrUtils , returns -1 if string not found e.g. Caption := IntToStr( IndexStr(FormatSettings.LongMonthNames[7], FormatSettings.LongMonthNames) + 1); EDIT: To avoid problems with casting and case sensitivity you might use IndexText as shown: Function GetMonthNumber(Const Month:String):Integer; overload;

DateFormat parse - not return date in UTC

夙愿已清 提交于 2019-12-27 16:05:55
问题 Here my java code that try to get current date in UTC on Android device: public static Date getCurrentDateUTC() { try { TimeZone timeZoneUTC = TimeZone.getTimeZone("UTC"); Date localTime = new Date(); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z"); dateFormat.setTimeZone(timeZoneUTC); String dateUTCAsString = dateFormat.format(localTime); Debug.d(TAG, "getCurrentDateUTC: dateUTCAsString = " + dateUTCAsString); Date dateResult = dateFormat.parse(dateUTCAsString); Debug

how to solve the error when convert string date to integer?

只愿长相守 提交于 2019-12-25 17:36:12
问题 I would like to convert my string date to int but I get an error, example of my date 'dim. janv. 23 24:00:00 +0000 2011` This is part of my code : String created_at = (String) jsonObject.get("created_at"); System.out.println("la date de création de tweet est: " + created_at); DateFormat df = new SimpleDateFormat(" ddd. MMMM. EE HH:mm:ss z yyyy"); String s= df.format(created_at); int out=Integer.valueOf(s); System.out.println("new date " +out); And the output is: java.lang

Convert Date String(yymmdd) to Date Object in JS

偶尔善良 提交于 2019-12-25 08:29:25
问题 I have a date string in "yymmdd" format i want to convert it into date object in JS the input string is "161208" I have tried code below var mydate = new Date(InputDate); but it says invalid date. Here is the fiddle https://jsfiddle.net/4ry0hL4t/ the basic need is that, I have a date string in "yymmdd" format and i have to convert it to different date formats like ("yyyy/mm/dd, yy-mm-dd","yy/mm"). 回答1: Check my answer. Basically you first need to give a proper format to your string. You can

Having trouble converting string (parsed from JSON) into javascript date object

烂漫一生 提交于 2019-12-24 03:09:07
问题 I am trying to create javasscript date object in the following way var object = {"name":"Bay Area Global Health Film Festival","start_time":"2013-07-08T19:00:00","end_time":"2013-07-08T23:45:00","timezone":"America/Los_Angeles","location":"San Francisco","id":"458415670892007","rsvp_status":"attending"} var tempDate = date(object.start_time); And I'm getting back the error: date is not defined I have also tried trimming the string using: var tempDate = date(object.start_time.slice(0,object

How to get Date part from given String?

做~自己de王妃 提交于 2019-12-23 12:47:34
问题 I have string like this: Mon, 14 May 2012 13:56:38 GMT Now I just want only date i.e. 14 May 2012 What should I need to do for that? 回答1: The proper way to do it is to parse it into a Date object and format this date object the way you want. DateFormat inputDF = new SimpleDateFormat("EEE, d MMM yyyy H:m:s z"); DateFormat outputDF = new SimpleDateFormat("d MMM yyyy"); String input = "Mon, 14 May 2012 13:56:38 GMT"; Date date = inputDF.parse(input); String output = outputDF.format(date); System

JQuery UI Datepicker parseDate 'Missing number at position 6'

别说谁变了你拦得住时间么 提交于 2019-12-22 08:34:30
问题 I need to parse dates like '070126' to '26 Jan 2007'. I thought I could use the datepicker, but it gives me the an error... $.datepicker.parseDate('ymmdd', '070126') #=> Missing number at position 6 I am starting to think that this could be a bug... $.datepicker.parseDate('y-mm-dd', '07-01-26') #=> Fri Jan 26 2007 00:00:00 GMT+0100 (CET) Any advice? Thanks.. 回答1: Are you sure it is not working? I have no problems with your code: http://jsfiddle.net/ND2Qg/ 回答2: Finally i just preprocessed the