Questions tagged [datetime-parsing]
423 questions
2
votes
4 answers
Parsing datetime of the format "2013-Jan-31" throws error
I have a datetime column in database.
DateTime end_date = DateTime.ParseExact("2013-Jan-31", "yyyy-MM-dd", CultureInfo.InvariantCulture);
Why isn't this working?

petko_stankoski
- 10,459
- 41
- 127
- 231
2
votes
2 answers
How to convert a Datetime String into a Datetime object
string DateCreated = "2012-05-24 12:34:40.060"; USA culture
How do I create the string into a Date time object with a format that include the month,
day, year, hour, minutes, seconds, milliseconds.
I think the format is this "MM/dd/yyyy hh:mm:ss.fff…

Yusuf
- 611
- 4
- 9
- 21
2
votes
7 answers
Regular Expression: match hh:mm, hh.mm or h
I'm looking for a regular expression to match different time formats (for a time tracking web-app) in javascript. The user can insert times with one of the following formats:
h
hh:mm
hh.mm
I can easily create a regular expression to match hh:mm and…

Slevin
- 4,268
- 12
- 40
- 90
1
vote
0 answers
datetime being saved is one second off in Rails app
I'm updating some datetime fields on one of my models. I parse a whole-minute time (like 12:30) using DateTime.civil, then assign it to the attribute. When I save and pull the data back out of the database, though it is off by a second (or less) -…

schwabsauce
- 399
- 5
- 16
1
vote
2 answers
DateTimeFormatter with multiple pattern not working
Both of these patterns working fine when tested separately but they are not working together in a single ofPattern { "[]" + "[]"} statement.
Please guide what am I missing here
import java.time.format.DateTimeFormatter;
import…

Sahib Yar
- 1,030
- 11
- 29
1
vote
3 answers
Parse non-UTC date string as UTC Instant, and print it out in another TimeZone
I am using Java 11.
I have a datetime string which looks like this
"2023-02-17T03:56:50.254"
But I know it represents a point in time in UTC time zone.
How do I parse this string taking into account it's actually in UTC (the parsing has to be…

peter.petrov
- 38,363
- 16
- 94
- 159
1
vote
0 answers
How to parse non-zero paded datetime string with strptime when leading zero is optional? Thanks
I've been trying to parse a datetime string in a file names with datetime.datetime.strptime().
import datetime
datetime.datetime.strptime('2023110912', "%Y%m%d%H%M")
datetime.datetime.strptime('202311912',…

Frank Li
- 97
- 1
- 5
1
vote
2 answers
how do you convert a date string that contains a monthname to a datetime?
I am sure this ust be simple, but the search engines lead me articals that answer everything but this :-(
I have a string "13 February 2023 13:45:40" that I need to convert to a datetime so I may do a comparison
How you cast a date like this? Does…

back_ache
- 382
- 1
- 13
1
vote
1 answer
ValueError in time-date data
I'm facing issue in matching the format of time date data
time data '03-MAY-22 02.42.33.000000000 AM' does not match format '%d-%b-%y %I.%M.%S.%f %p'
what should be the correct format for this date-time data?
For this time-date data '03-MAY-22…

Devendra Yadav
- 91
- 10
1
vote
1 answer
How can I format this value in java localdatetime?
Wednesday, 30 Nov 2022 10:30:00 (UTC)
12/08 (Thu), 10:00 GMT
Each item was extracted using regex from the data uploaded in this way.
With the selected items, we want to construct a localDatetime in Java.
Below is the code to configure…

sktom2
- 11
- 2
1
vote
0 answers
Unparseable date exception for the date format 2020-12-31T11:46:18.000+00:00
How do i parse a date with the format 2020-12-31T11:46:18.000+00:00
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
Date startDate = sdf.parse("2020-12-31T11:46:18.000+00:00");
I get Unparseable date exception. I have…

Amit
- 255
- 2
- 8
1
vote
1 answer
Java OffsetDateTime cannot be parsed
I want to parse the following String into an OffsetDateTime:
OffsetDateTime test = OffsetDateTime.parse("2021-12-31T23:00:00.000+00:00");
However, this results in an exception:
java.time.format.DateTimeParseException: Text…

Lars Wigger
- 23
- 6
1
vote
0 answers
Parsing a ZonedDateTime around the Daylight saving transition fails
I was testing the edge cases for my code and I ran into an unexpected effect with regards to parsing a ZonedDateTime in Java.
This parsing does not behave as I expect it in the Daylight savings transition from Summertime to Wintertime. This is the…

Niels Basjes
- 10,424
- 9
- 50
- 66
1
vote
1 answer
How to repeat local notification every day with dart-flutter? and how to parse '2:00 AM' time format To TimeZone?
I am trying to make a daily remainder to patient's medicine timings, I am using flutter_local_notifications and it works well.
this is my function i want to make it repeats daily,
void scheduleAlarm() async {
var…

Abd Elrahman Ashraf
- 33
- 2
1
vote
1 answer
DateTime.ParseExact - different outputs on Windows 10 and WinServer2012R2
I found out that this line:
DateTime.ParseExact("Jan 30", "MMM yy", null, System.Globalization.DateTimeStyles.None)
creates the date:
2030-01-01
...on my Windows 10 machine, but on Windows Server 2012 R2 the output is:
1930-01-01
Does anybody…

kraeppy
- 23
- 4