Skip to main content
Filter by
Sorted by
Tagged with
Advice
0 votes
13 replies
178 views

I am trying to replace Joda datetime and interval methods with Java.time and also trying to specify explicitly timezone as Duser.timezone=America/Chicago. This my code fragment public void ...
madhu's user avatar
  • 139
2 votes
0 answers
81 views

I have a spring boot webapp, which uses thymeleaf for html templating and as templating engine for emails sent by this webapp, too. In my email I want to use a LocalDateTime, which does not work. ...
dietzi96's user avatar
  • 133
4 votes
1 answer
585 views

DateTimeFormatter Java 8 introduced a modern date and time API with new types like LocalDate available in java.time.* package. It also provided a new DateTimeFormatter class for formatting (generating ...
Mahozad's user avatar
  • 26.4k
9 votes
7 answers
1k views

I need to iterate through the whole hours of an interval of a particular day. So given the time at one whole hour on the day in question, say, 01:00, how do I find the next whole hour? The next whole ...
Anonymous's user avatar
  • 87.4k
0 votes
0 answers
80 views

I am working on Spring Hateos Json APi. I have a Get request import static com.toedter.spring.hateoas.jsonapi.MediaTypes.JSON_API_VALUE; import org.springframework.hateoas.EntityModel; import java....
Thejas's user avatar
  • 527
-1 votes
3 answers
190 views

I'm currently migrating my codebase from Joda-Time to the java.time API (Java 8+). In one part of my application, I schedule tasks to run at a specific time either today or tomorrow, depending on ...
dragon4's user avatar
  • 11
2 votes
4 answers
238 views

In Java, I can easily truncate a temporal value (LocalTime, ZonedDateTime, etc.) to seconds, milliseconds, or any other value that has an existing ChronoUnit defined: LocalTime time = LocalTime.now(); ...
M. Justin's user avatar
  • 23.3k
0 votes
1 answer
129 views

I am working on replacing crnk with Spring Hateos Json APi . I was getting a exception for LocalDateTime so I have used @JsonSerialize(using = LocalDateTimeSerializer.class) @JsonDeserialize(using =...
Thejas's user avatar
  • 527
-1 votes
1 answer
166 views

I'm updating my code to use java.time.format.DateTimeFormatter instead of java.text.SimpleDateFormat and now a test fails which didn't before. When I parse the String 2010-12-31 00:00:00 , which in my ...
Loris's user avatar
  • 9
4 votes
3 answers
213 views

Both of these DateTimeFormatters are nearly identical, however only the second one throws an exception. Both of these patterns are valid as far as I can tell. Why does changing minWidth cause parsing ...
Steven's user avatar
  • 2,612
6 votes
4 answers
229 views

I am trying to parse durationString= P10YT10M using java.time.Duration.parse() method, but it fails with "Text cannot be parsed to a Duration". try { String durationString = "...
Vaibhav R's user avatar
0 votes
0 answers
27 views

I have been struggling to get my crossTab to group by "Month Year". I read that SimpleDateFormat is outdated. My dataset is using language domain. The coding is html style and lots of ...
Edward's user avatar
  • 896
5 votes
1 answer
191 views

I have a string: String inputDate = "18-FEB-24 10.02.33.578000000 AM"; I am trying to read it back and format it in YYYY-MM-DD HH:mm:ss.SSSSSS. I tried the SimpleDateFormat as well as ...
malife89's user avatar
-4 votes
2 answers
405 views

I have this Joda-Time date which I want to migrate to java.time.OffsetDateTime: import org.joda.time.DateTime; private DateTime createdDate; private String creationTime; ..... DateTimeFormatter dtf = ...
Peter Penzov's user avatar
0 votes
0 answers
40 views

I am converting a JSON to an object and it's giving me the following error: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type java.time.LocalDateTime not supported ...
smukh's user avatar
  • 99
0 votes
1 answer
293 views

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....
Peter Penzov's user avatar
3 votes
3 answers
122 views

Given a LocalTime add n minutes to it untill midnight and print those times to console. Example: public static void main(String[] args) { LocalTime start = LocalTime.of(10, 12, 0); ...
wannaBeDev's user avatar
6 votes
3 answers
241 views

We have some code which checks whether a given day is a leap day using org.joda.time. It is simply import org.joda.time.DateTime; DateTime date; return date.dayOfYear().isLeap() Is there an ...
Kirby's user avatar
  • 16k
2 votes
1 answer
245 views

I want to express periods in the day, such as in the morning, in the afternoon, or at night, not just AM or PM. Is there any pattern in java.time API to format and parse periods in a day, such as in ...
Arvind Kumar Avinash's user avatar
1 vote
1 answer
234 views

I need to handle an older set of data files, where among other infos, a local data time was serialized to the form "timeOfAcquisition":[2024,8,13,9,49,52,662000000] Younger files will ...
tabina's user avatar
  • 1,165
0 votes
2 answers
464 views

Let's get this over with. How do you convert a LocalDateTime to a java.util.Date without any "magic tricks" pulled by Java (which are becoming less and less amusing to me)? The year, month, ...
Cagepi's user avatar
  • 329
0 votes
1 answer
255 views

When I unit test for LocalDateTime with jdk 17, follow exception occurred. java.time.zone.ZoneRulesException: Invalid binary time-zone data: TZDB:America/New_York, version: 2024a here is my code: ...
Chenglin Zhao's user avatar
2 votes
2 answers
105 views

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 ...
isoplayer's user avatar
  • 103
0 votes
2 answers
140 views

is there any way to calculate calendar days between two dates. I tried with below code but looks like it gives 1 day as answer. But I am expecting the difference between this date is 2 days. No need ...
JAVA_CAT's user avatar
  • 881
-2 votes
1 answer
72 views

I have receive a timestamp in request as Integer format target_time = 1728962183 Then I want to use it to compare with LocalDateTime.now() to decide the code flow. Exp: if(target_time < ...
Bing Hao's user avatar
4 votes
2 answers
761 views

What is the difference between the java.util.TimeZone and java.time.ZoneId classes in JDK? Is there more information about the differences between the two to help me decide which class I should use in ...
Xi Minghui's user avatar
0 votes
0 answers
177 views

I have these 2 lines: DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss")).withZone(ZoneId.of("UTC")); String s = dateFormatter.format(Instant.now()); ...
grunt's user avatar
  • 732
5 votes
1 answer
525 views

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 ...
Ayush Jain's user avatar
2 votes
1 answer
111 views

I have a Java 8 application that has to accept any number of date and time formats from a user. Obviously that yields an exhaustive list, as there are many ways to write a date and time. For locale ...
S Hornby's user avatar
  • 115
0 votes
0 answers
96 views

I am using scala slick library 3.5.1. I have implemented DB tables for Oracle profiles with LocalDateTime columns. When trying to select data, insert data I am getting ORA-01830: date format picture ...
M. Barabas's user avatar
-2 votes
2 answers
48 views

I have 3 drop down menu to choose startTime, interval and endTime. Based on these threes, i wanna generate list of time units for nextIntakeTime for medicines. It works fine for smaller times like: ...
Himel's user avatar
  • 1
0 votes
1 answer
168 views

I have two LocalDate values. Say: LocalDate startDate = LocalDate.of(2020, 1, 1); LocalDate endDate = LocalDate.of(2024, 1, 31); I need to determine the actual month values (in a List, for example) ...
Stan Ostrovskii's user avatar
0 votes
3 answers
1k views

Problem I am currently trying to fix an issue with my Java Code. Essentially, I have to variables: currentTime of Type Instant and activeAfterSecond of type Duration (from the java.time package). ...
Palucca's user avatar
  • 35
3 votes
1 answer
158 views

It appears that Kotlin is very specific regarding the formats of Date. I am receiving a string in this "Jan 1 2023 12:00AM" and wanted to convert it into this "2023-01-01 00:00:00.0&...
Karan's user avatar
  • 866
3 votes
1 answer
683 views

I've developed a simple time picker app in jetpack compose. It consists of a text composable and a time picker. The text displays the selected time. However it doesn't display whether it is AM or PM. ...
Bob Rasner's user avatar
-3 votes
1 answer
153 views

I need to read a database table (sorted rows) with 300+ million TIMESTAMP as LocalDateTime in Java, and I need to get a single hash of all of them. Then, I need to get the same hash from the migrated ...
Joe DiNottra's user avatar
  • 1,083
4 votes
1 answer
156 views

You can tell how to configure ObjectMapper to automatically handle LocalDateTime class covered here: serialize/deserialize java 8 java.time with Jackson JSON mapper But when I try to use POJOs with ...
Nicholas DiPiazza's user avatar
-1 votes
1 answer
184 views

Recently I created a VM on Google Cloud Platform to run my .jar 24/7, and a part of my code is like: if (LocalTime.now().getHour() == 0) whenDateChanged(); I noticed that it runs at 12 am UTC+0, ...
Alex Cai's user avatar
-1 votes
2 answers
436 views

I've date format like Apr 1 2022 12:00:00:000AM and looking to convert it into 20220401 (yyyyMMdd).How can we convert the Date format import java.time.LocalDateTime; import java.time.format....
PAA's user avatar
  • 12.2k
3 votes
2 answers
212 views

Is there any way to use the Instant class in Java to get elapsed time in seconds to a certain number of decimal points? I took some time to experiment, and I was able to to use the .now() method at ...
ChicoTabi's user avatar
2 votes
1 answer
214 views

Consider the following: import java.time.*; var today = Instant.now(); var futureDay1 = today.atZone(ZoneId.systemDefault()).plusDays(1428826726); var futureDay2 = today.atZone(ZoneOffset.UTC)....
Mauro Molinari's user avatar
1 vote
2 answers
1k views

I am using java 8 version in my application, I have confused to use java date classes like java.util.Date and java.time.LocalDate at entity and dto level. Before java 8, we used to use either java.sql....
Anil Nivargi's user avatar
  • 1,747
2 votes
1 answer
334 views

I ran into a bug where java.sql's Timestamp.valueOf(LocalDateTime.MIN()) is converting incorrectly. Given java.time's LocalDateTime.MIN() = -999999999-01-01T00:00:00 But when I try to convert it ...
thekinggpin's user avatar
1 vote
1 answer
53 views

I want to create a model class that contains createdDate feild type as LocalDateTime using swagger contract, when implementing using swagger contract it is generating offsetDateTime as type in dto. ...
Keerthi's user avatar
  • 11
1 vote
2 answers
138 views

I'm trying to make the hours 1 or two digits and optional by modifying the ISO_LOCAL_TIME formatter. This is for parsing durations where hours can be optional. This is what I tried. new ...
John Mercier's user avatar
  • 1,709
2 votes
1 answer
85 views

I have a form where the date is entered and saved but the date is not binded when I go to edit the form. JSON: "checkOut": { "runDate": "2024-07-05T09:42:00.000Z", } ...
Elaine Byene's user avatar
  • 4,163
0 votes
1 answer
69 views

Spring batch using JdbcCursorItemReader for reader. and .setSql("select * from EMPLOYEE") Employee entity has a Date filed @Column(name = "CREATE_DATE_TIME") private LocalDateTime ...
Manu's user avatar
  • 1,263
0 votes
1 answer
67 views

I have a LocalDate field of an entiry class as below. @DateTimeFormat (pattern="dd-MM-YYYY") private LocalDate myDate; I have a Date object when printed displays Thu Jul 07 00:00:00 IST ...
itsraja's user avatar
  • 1,746
0 votes
1 answer
131 views

I was working on implementing test code for Google Calendar-related logic and came across a library called Fixture Monkey. To briefly explain, Fixture Monkey is a library that facilitates the creation ...
Kevin's user avatar
  • 810
0 votes
1 answer
83 views

I want to generate a listing report based on "listing status" and "createdOn" date on the MongoDB collection"processing-status". The "listingStatus" field ...
Arti M's user avatar
  • 21

1
2 3 4 5
42