Questions tagged [datetimeparseexception]

15 questions
6
votes
2 answers

ZonedDateTime format and parsing exception with “z” in format pattern

I have a problem with parsing ZonedDateTime: DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-ddzhh:mm"); ZonedDateTime.parse(s, formatter); This results in an error: java.time.format.DateTimeParseException: Text…
4
votes
2 answers

Parsing LocalDate but getting DateTimeParseException; dd-MMM-uuuu

I am trying to convert a String to LocalDate using DateTimeFormatter, but I receive an exception: java.time.format.DateTimeParseException: Text '2021-10-31' could not be parsed at index 5 My code is DateTimeFormatter formatter =…
3
votes
1 answer

DateTime TryParseExact fails when an array of formats is passed in PowerShell

Running the following PowerShell returns false when I'd expect true: $format = @('yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mm:sszzz', 'yyyy-MM-ddTHH:mm:ss') $provider = [System.Globalization.CultureInfo]::InvariantCulture $style =…
JohnLBevan
  • 22,735
  • 13
  • 96
  • 178
1
vote
2 answers

DateTimeFormatter with parseDefaulting throwing exception

I have private static final DateTimeFormatter DATE_PATTERN = new DateTimeFormatterBuilder() .appendPattern("yyyy-MM-dd[ ]['T'][HH:mm:ss][.SSSSSS][.SSSSS][.SSSS][.SSS][.SS][.S][X]") .parseDefaulting(ChronoField.HOUR_OF_DAY, 0) …
Dan OConnell
  • 217
  • 1
  • 8
1
vote
2 answers

java.time.format.DateTimeParseException: Text could not be parsed at index 20

java.time.format.DateTimeParseException: Text '2020-08-21T14:00:00.00+0700' could not be parsed at index 20 exception got for below code. ZonedDateTime.parse(iso8601DateString, "yyyy-MM-dd'T'HH:mm:ss.SSSZ") it worked in java 11 but it got exception…
Shine
  • 111
  • 1
  • 7
1
vote
2 answers

I have to get OffsetDateTime from a string

String is in this format - "2021-07-13 05:22:18.712" I tried using this code to parse it. OffsetDateTime parsedDateTime = OffsetDateTime.parse("2021-07-13 05:22:18.712"); But i keep getting this error - org.threeten.bp.format.DateTimeParseException:…
1
vote
2 answers

date and time show parse error at specific index

I am getting date and time from JSON API URL which format is like this '2021-03-05 09:18:07' which is in String form. but when I want to convert it in milliseconds it gives me an error of index 10. I don't know why this issue is coming I check…
1
vote
1 answer

JSON Parsing Date with DateTimeParseException/JsonbException from ClientBuilder/WebTarget program

I having problem parsing a date for JSON, when my program consumes a POST Services that contains a Body, Instead of REST client program Postman works perfectly. Using Postman with URL http://localhost:8080/api/v1/customers/createPurchaser With the…
joseluisbz
  • 1,491
  • 1
  • 36
  • 58
0
votes
0 answers

OffsetDateTime does not parse correctly the time when sending a defined time

OffsetDateTime does not correctly parse the time when a defined time is sent to me I have a service with a timezone UTC +4:00 I am sent two possible cases in STRING: 1- 2022-03-30T11:22:33.44+04:00 2- 2022-03-30T11:22:33.44+0400 but when I do…
0
votes
1 answer

DateTimeParseException could not be parsed at index 20

Why this code worked fine in intellij but throw an exception when running in Android studio? fun main() { val date = "Wed Mar 31 17:27:07 ICT 2021" println(date.toEpochSecond()) } fun String.toEpochSecond(): Long { val dbResponsePattern…
0
votes
3 answers

Text could not be parsed, unparsed text found

I am unable to figure out why I am getting the DateTimeParseException error when the text I am passing through fits the format. Below is the code that causes the issue: LocalTime lt = LocalTime.parse(songTime,…
0
votes
0 answers

How can I populate my JTable with Date and Time from a csv file?

So here is the link http://www2.hawaii.edu/~takebaya/ics111/jtable_basic/jtable_basic.html that I had been attempting to convert. 2011-12-22,12:28:51,12:28:53 2012-10-22,12:28:57,12:28:59 2010-10-22,12:29:10,12:29:12 Basically what I want is for my…
0
votes
2 answers

Format datetime with timezone

I need to parse any incoming date time string with a user specified locale and timezone to the sole pattern to properly store it in the database later: String inputDatetime = "Mon Dec 21 21:18:37 GMT 2020"; DateTimeFormatter fmt =…
-1
votes
1 answer

Text '28Feb2020' could not be parsed, unparsed text found at index 7

Input Text is 20FEB2020 The following code block throws a DateTimeParseException with the message Text '28Feb2020' could not be parsed, unparsed text found at index 7: String issueDate = abcIssueDate.substring(0, 3) +…
-1
votes
1 answer

java.time.format.DateTimeParseException: Text could not be parsed at index "dd.MM.yyyy HH:mm"

My code is: import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm"); String filterValue = "01.03.2021 0:01"; LocalDateTime parsedDate =…
Jens Kisters
  • 117
  • 2
  • 10