2,064 questions
Advice
0
votes
1
replies
93
views
Meaning of the documentation about OffsetDateTime
Recently, when I was reading the documentation for the OffsetDateTime class in Java, I came across a passage I didn’t understand:
It is intended that ZonedDateTime or Instant is used to model data in ...
Advice
0
votes
13
replies
6k
views
How to replace Joda dateTime and interval with Java.time
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 ...
Score of 2
0 answers
96 views
how to implement a ConversionService from LocalDateTime to String in spring boot
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.
...
Score of 4
1 answer
628 views
What is the difference between withLocale() and localizedBy() in Java DateTimeFormatter?
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 ...
Score of 9
7 answers
1457 views
Given a whole hour of the day, how to find the next whole hour?
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 ...
Score of -1
3 answers
301 views
Migrating from Joda-Time to java.time: How to replace time.toDateTimeToday().getMillis()? [closed]
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 ...
Score of 2
4 answers
261 views
How can I truncate time to tenths of a second?
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();
...
Score of 0
1 answer
134 views
Java LocalDateTime Serialized output is giving incorrect values
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 =...
Score of -1
1 answer
188 views
DateTimeFormatter with "yyyy-MM-dd HH:mm:ss" parses into LocalDateTime with missing seconds [duplicate]
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 ...
Score of 4
3 answers
253 views
Why does parsing with this DateTimeFormatter throw an exception?
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 ...
Score of 6
4 answers
262 views
Not able to parse P10YT10M ISO-8601 duration string in java
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 = "...
Score of 5
1 answer
208 views
Reading a string in java to proper Date format [duplicate]
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 ...
Score of -4
2 answers
723 views
Add timezone to java.time.OffsetDateTime
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 = ...
Score of 0
0 answers
45 views
java.time.ZonedDateTime error on JSON conversion to object [duplicate]
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 ...
Score of 0
1 answer
386 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....