Questions tagged [datetime-parsing]
423 questions
2
votes
1 answer
Not able to convert from HH:mm:ss.SSS'Z' to HH:MM format Java
I'm trying to convert into HH:MM format in Java
Here is my code
String date = "18:30:00.000Z";
try {
ZonedDateTime parsed = ZonedDateTime.parse(date);
ZonedDateTime z = parsed.withZoneSameInstant(ZoneId.systemDefault());
…

Syed
- 2,471
- 10
- 49
- 89
2
votes
2 answers
Zone adjustment not taken into account when parsing RFC 3339 date time
(Migrated from CodeReview)
I am experimenting and trying to understand Java Time better. My code is not working as expected and I want to ask the reason, probably because there is a misunderstandment from my side about JSR-310 time zone handling.
I…

usr-local-ΕΨΗΕΛΩΝ
- 26,101
- 30
- 154
- 305
2
votes
2 answers
ZonedDateTime ignores 00 for ss part
I am trying to convert string value "2018-10-11T12:00:00Z"; to ZonedDateTime.
If I use the default ZonedDateTime.parse(zonedDateTime) then ss portion i.e. 00 is removed and I get "2018-10-11T12:00Z" as output.
Can you please help how to retain 00 as…

sorab
- 321
- 1
- 4
- 15
2
votes
0 answers
How to ignore DST when parsing string to time (Time.parse) in Ruby
I need to parse strings with timestamps and convert them to Time objects.
I am struggling to understand how Time.parse works and how to ignore DST and use always UTC or simply convert to UTC
I keep having duplicate hours when time transition from…

Rojj
- 1,170
- 1
- 12
- 32
2
votes
2 answers
java to mysql. I need convert from string parametre to timestamp
I'm trying to parser String to Timestamp because I need to save this data on bbdd mysql.
String dateString: "2018-10-17T22:37:10.000+0000";
java.sql.Timestamp timeStampDate = null;
try {
DateFormat formatter;
formatter = new…

Kara
- 145
- 1
- 8
2
votes
1 answer
Parse all ISO 8601 DateTime formats Java 1.8
am using spring boot and Java 1.8 in my project. We are receiving a date string from an outside system which we need to parse. The problem is the outside system can send any DateTime that is ISO 8601 compliant and we need to parse any ISO 8601…

Anirban
- 925
- 4
- 24
- 54
2
votes
3 answers
How to parse two similar string to datetime in one formatter with joda?
Now I have two different formats of date written in string:
String date1 = "2018-10-12 18:01:01";// yyyy-MM-dd HH:mm:ss
String date2 = "2018-10-12 18:01";//yyyy-MM-dd HH:mm
I am using joda and I want to convert the string to DateTime,the basic way…

flyingfox
- 13,414
- 3
- 24
- 39
2
votes
1 answer
Java 8 DateTimeFormatter with optional part without seconds
There already exists question Java 8 DateTimeFormatter with optional part, but the answer for it won't work when optional part is only hours and minutes without seconds:
DateTimeFormatter patternWithOptional = new DateTimeFormatterBuilder()
…

andrybak
- 2,129
- 2
- 20
- 40
2
votes
3 answers
java.time.format.DateTimeParseException when milliseconds in 2 digit only
I am parsing the date like '2018-04-12 15:12:32.999' using java8 formatter. It works fine when i have a 3 digit milliseconds such as this date '2018-04-12 15:12:32.999', but it fails and throws an exception java.time.format.DateTimeParseException:…

Prasad Krishnegowda
- 21
- 5
2
votes
1 answer
Calendar set date causing exception with message "Unparsable date"
My code to get the calendar date frone the string "2018-04-14'T'15:38:14",
it is currently causing a exception WHEN i call setTime. The code
Calendar cal = Calendar.getInstance();
// format of date yyyy-MM-dd'T'HH:mm:ss
…

Ted pottel
- 6,869
- 21
- 75
- 134
2
votes
2 answers
DateTime.strptime can't parse date string
I don't understand why the following Ruby 2.4 code fails:
irb(main):006:0> require 'date'
=> false
irb(main):007:0> fmt = "%-m/%-d/%Y %-l:%M:%S %p"
=> "%-m/%-d/%Y %-l:%M:%S %p"
irb(main):008:0> DateTime.now.strftime(fmt)
=> "1/30/2018 7:42:44…

Joerg
- 3,553
- 4
- 32
- 41
2
votes
3 answers
java.time.OffsetDateTime: Unable to obtain OffsetDateTime from TemporalAccessor
I'm trying to parse "20140726080320+0400" using "yyyyMMddHHmmssZ" format as follows:
System.out.println("********************" + OffsetDateTime
.parse("20140726080320+0400",
…

Gaurav
- 157
- 1
- 2
- 8
2
votes
2 answers
Malformed Date Error Indexing Data Into Elasticsearch
I'm attempting to index data in elasticsearch that includes dates with time zones.
My date mapping is:
"date": {
"type": "date",
"format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
}
I use the following code to index the data:
client.prepareIndex(INDEX,…

Gabriel
- 624
- 1
- 7
- 20
2
votes
2 answers
Datetime parsing error
I am having problem parsing dates in Java. Below is the code.
String dateString = "2017-12-13T16:49:20.730555904Z";
List formatStrings = Arrays.asList("yyyy-MM-dd'T'HH:mm:ss'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS'Z'");
for (String…

Waqar Ahmed
- 5,005
- 2
- 23
- 45
2
votes
1 answer
ParseExact and TryParseExact methods are not accepting the multiple dateformats in powershell script
I have different types of date formats like MM/d/yyyy, MM/dd/yyyy etc.. I want to parse the different formats of string value to datetime in PowerShell.
[string[]]$format = @("MM/d/yyyy hh:mm:ss tt","M/d/yyyy hh:mm:ss tt","MM/dd/yyyy hh:mm:ss…

sandeep
- 53
- 7