675 questions
1
vote
0
answers
83
views
Indonesia java date format "Agt" [duplicate]
Currently, in Java I have tested using IBM SimpleDateFormat and Java DateTimeFormat, both cannot parse "Rab, 25 Agt 2025" due to IBM and Java only recognize "Agu"
Is there any ...
2
votes
2
answers
204
views
Error with Ktor and Exposed with LocalDate field in Postgres (ClassNotFoundException: kotlinx.datetime.Instant)
I have a small test table in Postgres with a DATE field, and data class in Ktor app. When mapping the database table row result to TestItem the 'updated' LocalDate field generated the error.
import ...
-1
votes
1
answer
163
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 ...
3
votes
2
answers
54
views
LocalDate to string format with HH:mm
I have a Kotlin code that retrives date (in text field) from SQLite DB and put it into a LocalDate variable (pill.startDay) from whom I show the date as below
val dtf: DateTimeFormatter = ...
0
votes
1
answer
89
views
LocalDate Format in SQLite Database Result error
I'm using SQLite for my database, but the result for date_logged is showing me an unexpected value, like 1731279600000, instead of the date I entered (e.g., 2024-11-12). I used H2 for my database ...
0
votes
1
answer
74
views
How to "put" LocalDate into SQLite DataBase
I need to insert a Date Field into an SQLite Database.
I am using Kotlin and I chose LocalDate class to handle Date.
I've created a class which has a field LocalDate:
data class Pillola(..., val ...
-1
votes
1
answer
134
views
Can't parse year-month string to LocalDate
I get this error while trying to pass the date 2024-12 in the following code:
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM");
LocalDate expiration = LocalDate.parse(exp,...
0
votes
1
answer
38
views
Is there a way to format a LocalDate to take just the month and year
I have a spring boot app that I want the admin to be able to get the system report based on the month and year selected. System report in this case is the number of sales that was made in the selected ...
2
votes
1
answer
58
views
Scala f interpolator formatting for Java LocalDate
I'd like to be able to format strings based on Java.LocalDate using the f interpolator, i.e. something like:
val = LocalDate.of(2024,7,28)
f"$dt:YYYY-MM-dd"
But this will give a compile ...
-1
votes
1
answer
336
views
Get LocalDate from the @RequestBody, convert it to dd/mm/yyyy format, convert it back to LocalDate and store it in the database
I am creating a Rest API applicaton which tracks users` expenses. I have date variable of type LocalDate and the default format is yyyy-mm-dd but I want to store dd/mm/yyyy in the database
what I ...
0
votes
0
answers
127
views
When attemping to cache book : Java 8 date/time type `java.time.LocalDate` not supported by default
When I'm trying to cache book in redis I'm running into this problem.
Config classes:
@Configuration
@EnableCaching
@RequiredArgsConstructor
public class CacheConfig {
private final ObjectMapper ...
2
votes
2
answers
957
views
Whats the point of Locale in DateTimeFormatter?
Given the following code
LocalDate localDateEpoch = LocalDate.parse(
"01-Jan-2017", DateTimeFormatter.ofPattern("d-MMM-yyyy", Locale.FRENCH));
System.out.println("...
1
vote
2
answers
1k
views
Which datatype to use at JPA entity to store and retrieve date using java 8
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....
0
votes
1
answer
67
views
Spring getting validation error with pattern dd-MM-yyyy
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 ...
0
votes
1
answer
28
views
DataSet encoding of map and sequence of LocalDate problems
I'm writing a solution in Scala based on Spark 3.5.0 that has complex map/seq data structures of dates where I need to represent missing dates with null or None. As this is scala my preference is None,...
0
votes
1
answer
78
views
How to convert date string to localDate when the month is not abbreviated
I am trying to convert the date string that has full month name using LocalDate but I am getting java.time.format.DateTimeParseException: Text could not be parsed at index 6
I tried looking online but ...
0
votes
0
answers
32
views
SpringBoot: dates are null in PUT petition to insert an object in a database
Trying to do a backend with Springboot. Now I'm trying to do petitions with postman to see if code works. For now, GET & POST are working. The problem comes whenever I'm doing a PUT petition with ...
0
votes
2
answers
66
views
String to LocalDate conversion issue
I have a SpringBoot 2.6.14 web-app with JPA 2.2 and Hibernate 5.
Now I have a String with this format
"2024-03-04T14:10:37.000Z"
And, following some instruction (googling around) I write ...
2
votes
0
answers
158
views
LocalDate.parse does not validate leap years
DateTimeFormatter formatters = DateTimeFormatter.ofPattern("uuuu-MM-dd");
endDate = LocalDate.parse(endDateString, formatters);
Why does the above code not throw exceptions for leap years?
...
0
votes
1
answer
50
views
why am I getting an error on calling clothing.getLastWornDate() method? [closed]
I am working on a Java assignment for school. In this method, I am trying to save to a file as described by assignment, but I am getting an error when calling clothing.getLastWornDate() and am lost as ...
0
votes
1
answer
78
views
How to compare expiry date to today date?
I'm trying to compare two dates using LocalDate in my Expire date table. The problem is that I cannot set properly row formatting according to dateExpiry.
This is how it should look:
if (today....
0
votes
1
answer
51
views
updating a field in MongoDb using Java Sync driver
I have tried to update a field in the MongoDB database namely the "Status" field (of type integer) only between two dates FromDate and ToDate.
no errors or warnings were obtained, however, ...
1
vote
1
answer
371
views
LocalDate.parse fails for DateTimeFormatter with multiple patterns
You can create a DateTimeFormatter with multiple patterns using the DateTimeFormatterBuilder, but LocalDate.parse doesn't seem to like it. It works with a single pattern and fails with mutliple ones.
...
2
votes
1
answer
4k
views
How to use java.time classes correctly?
I know this may sound awkward after 3 years of software development, but I'm trying to better understand the java.time classes and how to use them to avoid errors and bad practice.
On the first ...
1
vote
2
answers
125
views
How to find Start date from time elapsed as percentage and End date in java
i have below code
End date = 31 oct 2024 and
elapsedPercentage is 10% of total duration on current date
as per above params
expected Start date value is 12 aug 2023
but i am getting 07 Dec 2023 ...
0
votes
1
answer
177
views
How to group and reduce a list of objects with duration
I want to create a list of persons sorted by LocalDate and String as well as aggregated by duration.
I did some research regarding the use of duration in streams:
How to get the average duration for ...
0
votes
0
answers
63
views
List has custom object with overlap date ranges need to break all overlap ranges into new periods and keep non overlap AS IS in java
Consider below example , inputList has overlap date ranges
inputList.add(new DateRange(LocalDate.of(2023, 7, 1), LocalDate.of(2023, 7, 10)));
inputList.add(new DateRange(LocalDate.of(...
0
votes
2
answers
221
views
Java Timezone issue with LocalDate not showing correct date
I'm currently based in Europe/London
I am trying to get the current day in Samoa, which is 27 July with the following code:
LocalDate localDate = LocalDate.now(ZoneId.of("Pacific/Samoa"));
...
0
votes
0
answers
94
views
Iterating through LocalDate range groovy list
This used to work under Groovy 3.x version but fails in 4.x
LocalDate startDate = LocalDate.of(2023, Month.JULY, 1)
LocalDate endDate = LocalDate.of(2023, Month.JULY, 31)
LocalDate[] ...
-1
votes
2
answers
212
views
Querying dates within months using only numerical values months
I have 2 date values and a set of rows which have a range defined as discount_start_month and discount_end_month. The current situation is that I only have month information as below, there is no year ...
0
votes
1
answer
841
views
Converting LocalDate to java.util.Date [duplicate]
I'm trying to convert a java.time.LocalDate to java.util.Date, but I lose some days in the process.
Here the code that shows the issue:
public static void main(String[] args) {
var localDate = ...
2
votes
1
answer
158
views
LocalDateTime not parsing for a specfic device [duplicate]
I am parsing a String to LocalDateTime (by ThreeTen, not the Java one) with this method.
for input: 28-Aug-20 10:37:41 AM BST
private fun toLocalDate(date: String?): LocalDateTime? {
return ...
2
votes
1
answer
224
views
Period between LocalDates produces wrong results
I see that java.time.Period with java.time.LocalDates works mostly as desired and I can use it to get the duration between two dates in years, months and days but I found an example that is not ...
0
votes
2
answers
776
views
Java Converting Retrieved TimeStamp to Instant Gives Wrong Day
I've made a simple method which is used to convert a timestamp retrieved from a database into a LocalDate. However for some reason I keep getting the wrong day in the conversion. I've shared the code ...
0
votes
1
answer
1k
views
How do I cycle through a range of dates in kotlin?
In my android project I need to go through data base and take some values from a current record, but only if this record has the date I need.
I tried googling it and i dont think there is a good ...
1
vote
1
answer
627
views
LocalDateTime (or any other suitable class) with time as optional paramter
I am trying to parse an incoming string which might contain time or not. Both the following dates should be accepted
"2022-03-03" and "2022-03-03 15:10:05".
The DateTimeFormatter ...
-1
votes
1
answer
269
views
Thymeleaf input date don't show and don't receive value with LocalDate
I have in my form any inputs with date value, but don't show value. If I input the date when sent to backend don't receive this information. I use LocalDate
I'm use this dependencies:
<dependency&...
1
vote
1
answer
120
views
Why is the below SimpleDateFormat showing incorrect date? [duplicate]
I am trying to validate incoming date string and then convert it to a LocalDate. Here is my code:
public class DateTester {
public static void main(String[] args) {
System.out.println(&...
1
vote
2
answers
1k
views
How to Mock LocalDate.now() in Scala
I have object
object func1{
def something(arg1: Int): String{
// var date = something2()
// Using date
}
def something2(): LocalDate{
LocalDate.now()
}
}
I want to ...
3
votes
1
answer
73
views
Define the highest time unit of date difference that has a whole number
I have 2 dates:
LocalDate date1 = LocalDate.now().minusDays(40);
LocalDate date2 = LocalDate.now();
I want to figure out what is the biggest time unit I can pick to define the difference between the ...
1
vote
2
answers
682
views
Java8 DateFormatter for pattern "Dec 01, 2019 1:00:00 PM +00:00"
I am trying to format the String date, time and zone information.
LocalDateTime.parse("Dec 01, 2019 1:00:00 PM +00:00", DateTimeFormatter.ofPattern("MMM dd, YYYY hh:mm:ss a XXX"));
...
1
vote
1
answer
5k
views
how compare localdatetime with current date including hours in java
My Local date Time(Shipping) in the format like "2023-01-11T01:25:59"
I need to compare with current time do the below conditions
If both are in same date and Shipping hour more than ...
2
votes
1
answer
2k
views
Spring boot convert epoch timestamp to java.time.LocalDate?
I want to compare LocalDate with the timestamp in database (Postgres with UTC timezone).
code I wrote
@Query("""
select eve from Events eve
where cast(to_timestamp(pe....
-2
votes
1
answer
142
views
calculate the expiry in working hours and working days java
The expiry should be after 8 working hours (8 am to 5 pm UTC monday to Friday) for example the created date at 7 pm UTC time, the expiring time should be counted from next morning 8 am to 5 pm UTC ...
1
vote
1
answer
163
views
Is there a way to set alarm in android with local date and local time?
I am building a Calendar app to save events, show them and edit them with DatabaseHelper. I want to add alarm to these events but every I can find only setting alarm with Calendar import library. I ...
3
votes
3
answers
822
views
Is it possible write a custom date format in a way that works for all locales in Java?
My goal is to display a date in a format like:
Country
example
pattern
US
Tue, Jan 3
EEE, LLL d
France
mar. 3 janv.
EEE d LLL
I'm using DateTimeFormatter.ofPattern to format my dates.
Is there a way ...
0
votes
1
answer
2k
views
Java converting localDate 0001-01-01 to date issue
I have two localDate to convert: 2022-11-02 and 0001-01-01
I am using the same method:
Date.from(myLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant())
LocatDate 2022-11-02 is fine with result ...
2
votes
1
answer
242
views
Find the minimum birthdate of people based on a given age?
In my app, I want to filter data based on age range. The problem is that I didn't store the age in the database so I have to use the birthdate.
This is what I did so far but it's incorrect:
public ...
-1
votes
1
answer
86
views
Convert a date to another format date using LocalDate [duplicate]
Can I know how can convert one date format to another date format.
public static LocalDate localDateToAnotherLocalDate(String oldPattern, String newPattern, String input) {
DateTimeFormatter ...
-1
votes
1
answer
2k
views
java.sql.Date.valueOf(java.time.LocalDate) not recognized and LocalDate formatting
The code below gives me the error 'valueOf(java.lang.String)' in 'java.sql.Date' cannot be applied to '(java.time.LocalDate)', which I understand means that valueOf is expecting a string... but ...