459 questions
0 votes
1 answer
271 views
could not be parsed: Unable to obtain OffsetDateTime from TemporalAccessor
I have this java code: import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; import java.util.Date; DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormat....
2 votes
2 answers
103 views
DateTimeParseException when parsing 01-FEB-25 12.00.00.000000 AM UTC, where is the issue?
I have the following Java (version 8) code that parses a date time string that looks like '01-FEB-25 12.00.00.000000 AM UTC'. Expected result is a ZonedDateTime of 2025-02-01T00:00Z[UTC]. But I keep ...
3 votes
3 answers
153 views
Android SimpleDateFormatter Parse Exception
I have some old Java code that attempts to parse a string using SimpleDateFormat. It is frequently throwing a ParseException: Non-fatal Exception: java.text.ParseException: Unparseable date: "06:...
5 votes
1 answer
508 views
Does Java's DateTimeFormatter allow lenient parsing for fractional seconds?
I am currently working with Java's DateTimeFormatter to parse ISO 8601 formatted timestamps, particularly those containing fractional seconds. While experimenting with different timestamp formats, I ...
1 vote
2 answers
358 views
Parse "12:00 a.m." as TimeOnly [duplicate]
I'm struggling with parsing strings ongoing in the "12:00 a.m." format. I tried TimeOnly.TryParse("12:00 a.m.", CultureInfo.InvariantCulture, out var result), but it doesn't work. ...
0 votes
2 answers
425 views
Java ZonedDateTime.parse not working as expected
I am using Java 17. I am trying to parse different strings as ZonedDateTime but when I try to convert it to an Instant, the output is not as expected. For eg: String first = "2020-01-...
0 votes
1 answer
269 views
Is there any standard way of parsing RFC3339 compliant dateTime instead of using patterns in java?
Is there any standard way of parsing RFC3339 compliant dateTime instead of using patterns in java ? It seems there isn't one. I tried finding solution over the internet but most of them were using ...
2 votes
1 answer
721 views
I got the error "java.text.ParseException: Unparseable date: "1/10/24 7:00 PM"" when trying to parse
I have a date string as "1/10/24 7:00 PM" (10th Jan.2024). How to parse it using SimpleDateFormat? String date_time = "1/10/24 7:00 PM"; Instant answer; try { answer = Instant....
1 vote
3 answers
821 views
Parse string date to millis in kotlin
I am using SDF to parse a string date to millis with below code private fun dateToMilliseconds(dateValue: String): Long? { val sdf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS") val date: ...
3 votes
1 answer
330 views
Date Parse Exception in Android for input Mon, 11 Sep 2023 15:49:32 GMT
fun calculateAge(dateString: String): String { val dateFormat = SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z") dateFormat.timeZone = TimeZone.getTimeZone("GMT") ...
1 vote
2 answers
232 views
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 ...
-1 votes
3 answers
195 views
How to convert Timestamp in CDT Format to MM/DD in Java?
I have a timestamp in cdt format as below "2023-06-05T09:00:01CDT", I want to convert this timestamp into MM/DD format in Java. I have tried below : The expected output was: 6/5 But was ...
-1 votes
1 answer
2k views
Unable to obtain LocalDateTime from TemporalAccessor: when trying to sort the date in the stream
I want to sort the posts by date("hh:mm:ss"). but I get a mistake. Can you tell me what I did wrong? java.time.format.DateTimeParseException: Text '12:55:36' could not be parsed: Unable to ...
0 votes
1 answer
1k views
Get period between two times
I have two string time. How can I get a duration of period between theese two time? I try to use DateTimeFormatter, but it doesn't work. val startTime = LocalDate.parse("19:30", ...
1 vote
3 answers
2k views
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 ...