Questions tagged [datetime-parsing]
423 questions
4
votes
5 answers
How to convert "2020-12-20T00:00:00.000Z" to java.util.Date?
I tried to use
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH);
LocalDate date = LocalDate.parse(d.toString(), formatter);
but it throws an error.
Is there any way to convert the JSON…

user1688726
- 319
- 2
- 4
- 11
4
votes
1 answer
Java LocalDateTime parsing
Why can I parse a date time string in java with an invalid hour? What have I missed or need to do to ensure that it throws an error appropriately.
The following code does not throw an error, where it should?
DateTimeFormatter dateTimeFormatter =…

Simon Laing
- 1,194
- 7
- 18
4
votes
2 answers
time.Parse in Go with varying fractional second length
I am parsing a timestamp from a DB. My layout is the following:
layout = "2006-01-02 15:04:05.000000000 -0700 MST"
pipelineTS, err := time.Parse(layout, rawPipelineTS)
The issue is that sometimes the fractional seconds are not 9 digits, for…

MarekT
- 104
- 8
4
votes
1 answer
Gson java.lang.IllegalArgumentException: No time zone indicator
I have weird bug working with Gson.
I have created it like this
mGson = new GsonBuilder().registerTypeAdapter(beelineItemType, new ItemsDeserializer()).setDateFormat("yyyy-MM-dd'T'HH:mm:ss").create();
and my json object is like this:
"EpgStartDate"…

Kimi95
- 55
- 1
- 5
4
votes
2 answers
Convert String into java.time.ZonedDateTime
I want to convert elements of an array list into ZonedDateTime object after parsing them. A string is shown below.
"2017-02-12 06:59:00 +1300"
At the moment I use the DateTimeFormatter:
DateTimeFormatter dateTimeFormatter =
…

SSF
- 915
- 5
- 23
- 47
4
votes
2 answers
Parse date-time from String with offset with one-digit hours
I need to parse date in Java. I have String value 2018-05-15 09:32:51.550082 +3:00 and I need to parse it into date-time. I tried to parse to ZonedDateTime, but I got an error at index 10. Tried to parse with DateTimeFormatter parser 'yyyy-MM-dd…

tomasomsk
- 81
- 10
4
votes
2 answers
Java 8 Date time formatter misbehaving
I have the following piece of code that is throwing a DateTimeParseException:
String dateString = "Jul 20 09:32:46"
DateTimeFormatter formatter=DateTimeFormatter.ofPattern("L d HH:mm:ss");
return ZonedDateTime.parse(dateString,…

user1676688
- 414
- 4
- 15
4
votes
1 answer
java.time.format.DateTimeParseException could not be parsed at index 0
I am trying to tell Gson how to parse LocalDateTime and LocalDate, but I'm getting this error, which looks to me like it should match the format. I'm thinking there's either something I don't understand about parsing dates or something I don't…

Steve
- 4,457
- 12
- 48
- 89
4
votes
1 answer
Java DateTimeFormatterBuilder with Verbose Time Zone
Suppose I have a date such as:
Nov 30, 2013 19:00:00.001930000 Eastern Standard Time
I'm trying to parse the input using DateTimeFormatterBuilder, but I can't figure out what to put for the Set of generic type ZoneId which is null below.
String…

squirrelsareduck
- 874
- 1
- 10
- 15
4
votes
3 answers
How to Pick Timezone from ISO 8601 format String into a Calendar instace
As an input I have a string which is a String in ISO 8601 to represent date. For example:
"2017-04-04T09:00:00-08:00"
The last part of String, which is "-08:00" denotes TimeZone Offset. I convert this string into a Calendar instance as shown…

Tarun Deep Attri
- 8,174
- 8
- 41
- 56
4
votes
4 answers
How to convert timestamp string to epoch time?
I have time stamp in format 2017-18-08 11:45:30.345.
I want to convert it to epoch time, so I am doing below:
String timeDateStr = "2017-18-08 11:45:30.345";
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-dd-MM…

User7723337
- 11,857
- 27
- 101
- 182
4
votes
3 answers
Time parsing issue on Android
I am getting a parse exception when trying to parse the time string 02:22 p.m..
I have the following conversion function:
public static long convertdatetotimestamp(String datestring, String newdateformat, String olddateformat){
SimpleDateFormat…

SARATH V
- 500
- 1
- 7
- 33
4
votes
2 answers
DateTimeFormatter doesn't parse custom date format
I have an issue with java DataTimeFormmater.
I feel that I missed something but cannot figure out what exactly.
String format = "yyyy-MM-dd'T'HH:mm:ss[.S]'T'zxxx";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
String date =…

endryha
- 7,166
- 8
- 40
- 64
4
votes
2 answers
DateTimeFormatter Accept Multiple Types and Convert to One
I am trying to write a DateTimeFormatter that will allow me to take in multiple different string formats, and then convert the string formats to a specific type. Due to the scope of the project and the code that already exists, I cannot use a…

AlexK
- 336
- 8
- 21
- 41
4
votes
3 answers
Java date format - GMT +04:00
I have to parse the following date
Fri Sep 30 18:31:00 GMT+04:00 2016
and it is not working with the following pattern:
new SimpleDateFormat("EEE MMM dd HH:mm:ss z YYYY", Locale.ENGLISH);
I get the following date as output: Fri Jan 01 18:31:00…

Oktay Alizada
- 53
- 1
- 3