Questions tagged [date-parsing]

Date-parsing refers to programming logic which reads one or more parameters, attempts to match it to a supported or specified date format, then returns the resulting Date if successful.

References

494 questions
1
vote
2 answers

Java, SimpleDateFormat produces ParseException in German. Works in English

My app is calling up a Twitter feed and a blog feed, both contain a post date of course. When my phone is set to English locale it works, when I switch to Dutch or German it fails. The code in question does not even call upon the locale, and the…
Wouter
  • 2,623
  • 4
  • 34
  • 43
1
vote
0 answers

Inconsistent date string parsing by Date().toISOString() in V8

Paying with new Date().toISOString(), I observe an inconsistency in parsing of the same date in different string formats: 2020-01-01 and 2020/01/01: const opt1 = new Date("2020-01-01").toISOString(); document.write(`"2020-01-01":…
Mike
  • 14,010
  • 29
  • 101
  • 161
1
vote
0 answers

How do I use the jFormattedTextfield in Java GUI for entering dates only

I am new in Java programming language and I want to constrain the user to input dates in this format pattern only (dd/mm/yyyy). I am using Java Swing controls for drag and drop. please help.
Emmanuel
  • 11
  • 3
1
vote
1 answer

NodaDateTime ZonedDateTimePattern Parse not recognising offset

Can't get NodaDateTime to recognise any other offset than UTC in format: +HH The following works fine: var pattern = ZonedDateTimePattern.CreateWithInvariantCulture("dd/MM/yyyy HH:mm:ss +o", DateTimeZoneProviders.Tzdb); var dateString =…
1
vote
1 answer

DateTimeFormatterBuilder with default zone id?

I have a requirement where if ISO date time does not specify zone offset, I should assume Europe/Bratislava's current offset. Basically "2020-03-26T22:47:32.497" -> "2020-03-26T22:47:32.497+01:00" Tldr; do parse time zone id if there is one, but…
urSus
  • 12,492
  • 12
  • 69
  • 89
1
vote
2 answers

Error converting date with two digits for the Year field

// input format: dd/MM/yy SimpleDateFormat parser = new SimpleDateFormat("dd/MM/yy"); // output format: yyyy-MM-dd SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); System.out.println(formatter.format(parser.parse("12/1/20"))); //…
1
vote
1 answer

Solr not accepting the "yyyy-MM-dd" date formating with tdate (TrieDateField) field

I am using Solr 7.7.2 version. I have defined field called date_test with type tdate(TrieDateField) as given below inside the {core}/conf/schema.xml file
Vishal Zanzrukia
  • 4,902
  • 4
  • 38
  • 82
1
vote
2 answers

Is there an efficient way to check if a string represents a date?

I am given a txt with some specific format. The format is supposed to be starting with dd/MM/uuuu. However i would like to check if it is indeed this specific format or else my code will break. Now my thoughts were to check if the specific 10 first…
Kostas Thanasis
  • 368
  • 4
  • 11
1
vote
2 answers

Java8 equivalent of JodaTime DateTimeFormat.shortDate()

What is the Java8 java.time equivalent of org.joda.time.formatDateTimeFormat.shortDate() I've tried below way, but it fails to parse values such as "20/5/2016" or "20/5/16". DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT)
wilmol
  • 1,429
  • 16
  • 22
1
vote
1 answer

DateTimeParseException: Text '2019-08-13T07:29:12.000+0000' could not be parsed, unparsed text found at index 23

Getting a DateTimeParseExcpetion when trying to convert a String 2019-08-13T07:29:12.000+0000 into an OffsetDateTime. The String comes from SalesForce OffsetDateTime.parse("2019-08-13T07:29:12.000+0000",…
Alec
  • 13
  • 1
  • 3
1
vote
3 answers

How to extract JSON data in customized format?

I have the Json data like {"no":["1","2","3"],"date":["23/05/1992","02/01/1991","01/05/1992"]} I want to split in to correct format in java.
V. Monisha
  • 89
  • 6
1
vote
1 answer

How to parse different date strings to LocalDate/Year?

I get list of objects from Json, each of them includes date String. There are two different formats, one is standard "yyyy-MM-dd" format, second is just year "yyyy". What is the elegant way to parse these string to unix timestamp? At the moment i am…
1
vote
2 answers

Pandas Value-Error: "time data 'nan' does not match format", when using "read_csv" with "date_parser" and "comment"

I am using: Python 3.7.2 & Pandas 0.24.2 And I try to read the following data (data.txt). Separated by whitespace, first column should be parsed as datetime objects: #00:00:00 col0 col1 2019-03-28_08:58:00 1064 …
neo
  • 49
  • 2
  • 7
1
vote
1 answer

Parsing a date with pattern 'dd MMMMM uuuu' using DateTimeFormatter

Why this code give me an Exception? String myFormat = "dd MMMMM uuuu"; String dateToFormat = "26 Mai 2010"; DateTimeFormatter myFormatter = new DateTimeFormatterBuilder().appendPattern(myFormat) …
Neo
  • 1,337
  • 4
  • 21
  • 50
1
vote
1 answer

Find pattern of unknown date string

Fairly new to Java but trying to figure out how to solve a problem I came across. I read through many articles on formatting unknown date/time in Java as I know you need to first know the pattern of the date before you can start to parse the date.…
James Zilch
  • 1,055
  • 2
  • 10
  • 17