Questions tagged [datetime-parsing]

423 questions
2
votes
1 answer

Parse date from json in Django

I try to parse date field inside JSON object: { "year": 1, "name": "marko", "date": "2015-10-1 3:00 PM GMT+1:00" } I try to something like: db_object.date = datetime.datetime.strptime(dictionary.get('date'), '%Y-%m-%d %I:%M ') but I…
Marko Zadravec
  • 8,298
  • 10
  • 55
  • 97
2
votes
1 answer

Jackson not parsing Timestamp correctly

I'm having trouble parsing java.sql.Timestamp from XML files using Jackson 2.8.5. Somehow the milliseconds are padded with zeros on the left side. Here is a minimal example showing that : public class Foo { @JacksonXmlProperty(localName =…
2
votes
1 answer

Formatting ISO 8601 in Java 7

I have date format like this 2016-11-25T09:29:10.588+01:00 I want to convert this to milliseconds and later while printing I have to again convert milliseconds to "yyyy-MM-dd HH:mm:ss.SSS" this format. static FastDateFormat alarmDateFormat =…
Harsha G
  • 39
  • 1
  • 4
2
votes
1 answer

milliseconds format to parse a datetime?

I need to parse a datetime contains milliseconds for matching the max value in a field containing this datetimes. For example: #standardSQL SELECT PARSE_DATETIME('%Y-%m-%d %H:%M:%S.%u','2017-08-18 16:04:40.890') Any suggestions? Thanks in…
Mario M.
  • 802
  • 11
  • 26
2
votes
2 answers

Spring Boot parse form data to ZonedDateTime (dd/MM/yyyy HH:mm)

I have an entity which has java.time.ZonedDateTime property. I want to parse a string submitted from form in dd/MM/yyyy HH:mm format to java.time.ZonedDateTime. I tried @DateTimeFormat(pattern = "dd/MM/yyyy HH:mm"). But it works only LocalDate with…
Ibrahim
  • 1,341
  • 1
  • 11
  • 24
2
votes
1 answer

DateTimeFormatterBuilder fail to chose format

I've configured formatter: public static final DateTimeFormatter DATE_FORMATTER = new DateTimeFormatterBuilder() .append(forPattern("yyyy-MM-dd")) .append(forPattern("MM/dd/yy")) .append(forPattern("MMM dd, yyyy")) …
Mike
  • 20,010
  • 25
  • 97
  • 140
2
votes
1 answer

How do you parse basic (short/compact) ISO:8601 string with Joda?

I have a time string, which looks like this: 20170822T194135+00. This is called basic ISO:8601 format, if I understood correctly. When I try to parse it using ZonedDateTime, it throws exception, complaining that it can't parse it. SO, how do I…
Slava Fomin II
  • 26,865
  • 29
  • 124
  • 202
2
votes
4 answers

How to unify date format using DateTimeFormatter

I need to parse different time format into BASIC_ISO_DATE. Right now, there are 4 types of date format: 2016-10-01 (ISO_LOCAL_DATE) 2016T 201610T 2016-02-07T22:03:39.937Z (ISO 8601) Need to parse to 20161001 and print out, with default day is 01,…
Meng Li
  • 65
  • 1
  • 7
2
votes
2 answers

Convert string to date (CEST works fine, GMT+02:00 doesn't work)

Question Why is my Android app unable to parse String str1= "Tue Jun 20 15:56:29 CEST 2017"? I found some similar questions, but none of them helped me. Sidenotes In my project I have some Java applications which are running on a computer and some…
Deweird
  • 49
  • 1
  • 1
  • 8
2
votes
3 answers

Parsing time with DateTimeFormatter "hh:mm a" cause Exception

I have already checked many solutions online but still got the exception when parsing "hh:mm a". In JSP: $('#t2').timepicker({ timeFormat : 'hh:mm a', interval : 30, maxTime :…
Chenya Zhang
  • 463
  • 3
  • 11
  • 22
2
votes
2 answers

Python parse datestring to date

I am trying to parse a datetime string to date in Python. The input value is of the form: "February 19, 1989" I have been trying so far datetime.datetime.strptime("February 19, 1989", "%B %d, %y") but I am always getting error. What is…
Crista23
  • 3,203
  • 9
  • 47
  • 60
2
votes
2 answers

Python parsing date and find the correct locale_setting

I have the following date string: '3 févr. 2015 14:26:00 CET' datetime.datetime.strptime('03 févr. 2015 14:26:00', '%d %b %Y %H:%M:%S') Parsing this failed with the error: ValueError: time data '03 f\xc3\xa9vr. 2015 14:26:00' does not match format…
2
votes
4 answers

Create DateTime object from various strings

I have a string that is in the format of a date. I want to convert it to a DateTime object. However I am not certain of the format of the string. Are there any methods that I can use so that it will work on following inputs? "12/31/2015",…
Sperick
  • 2,691
  • 6
  • 30
  • 55
2
votes
2 answers

Forcing DateTime.Parse to Fail for Invariant Dates

I'll be brief to start, then give details at the end. Consider the following code: CultureInfo cultureToTest = new CultureInfo("hu-HU"); Thread.CurrentThread.CurrentCulture = cultureToTest; DateTime testDateTime = new…
John Saunders
  • 160,644
  • 26
  • 247
  • 397
2
votes
1 answer

How do I parse ISO 8601 date without year using DateTimeOffset?

I need to parse ISO 8601 dates that does not contain a year and probably month component, such as: --0412T102200Z I am trying to use the following code which throws exception 'There must be at least a partial date with a year present in the…
IT Hit WebDAV
  • 5,652
  • 12
  • 61
  • 98