2,065 questions
Advice
0
votes
13
replies
182
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 ...
2
votes
0
answers
81
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.
...
4
votes
1
answer
589
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 ...
9
votes
7
answers
1k
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 ...
-1
votes
3
answers
200
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 ...
2
votes
4
answers
243
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();
...
0
votes
1
answer
130
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 =...
-1
votes
1
answer
169
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 ...
4
votes
3
answers
223
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 ...
6
votes
4
answers
234
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 = "...
0
votes
0
answers
27
views
Jasper Studio crossTab, rowGroup DateTime to "Month Year"
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 ...
5
votes
1
answer
192
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 ...
-4
votes
2
answers
453
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 = ...
0
votes
0
answers
42
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 ...
0
votes
1
answer
320
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....