All Questions
4,611
questions
0
votes
0
answers
88
views
java.util.Date converted to LocalDate returns Strange results [duplicate]
Date date = new Date();
Calendar cal1 = Calendar.getInstance();
cal1.set(Calendar.YEAR, 0001);
cal1.set(Calendar.DAY_OF_MONTH, 1);
cal1.set(Calendar.MONTH, Calendar.JANUARY);
cal1....
-2
votes
1
answer
82
views
LocalDateTime - issue in time display in database
I need to save a date with time in an Oracle database.
I have used LocalDateTime in my entity, and the date with time is showing correctly in the Eclipse console, but there is a mismatch in time when ...
1
vote
1
answer
52
views
Read Date from excel and insert into PostgreSQL
I have problem while reading date from Excel file using Apache Poi.
I use the following:
FileInputStream inputStream = new FileInputStream(excelFilePath);
Workbook workbook = new XSSFWorkbook(...
-1
votes
1
answer
75
views
supress Java checked Exception [duplicate]
I have writen the following code. I know it might not be the correct approach. but this is what i have done.
public class ValidationRule {
private static SimpleDateFormat sdf = new ...
4
votes
4
answers
204
views
Java - How to set a file time before 1970?
With the following code
long newDate = Date.parse("12 Oct 1960 13:25:00");
file.setLastModified(newDate);
I get java.lang.IllegalArgumentException: Negative time
And with this code
...
3
votes
2
answers
286
views
Date String with Time Zone Offset
I have to process an input file that contains "dates with offsets" (like 2024-04-29+02:00). Basically, I know how to parse that … but I have no real idea which target type I have to choose – ...
0
votes
4
answers
136
views
Calculations for date
There is a scenario where some notifications are thrown. As a user, I will be setting a password. There will be an expiry date for the password that has been set. Say it is going to expire on 14/07/...
0
votes
0
answers
68
views
How to get the right timezone in Java with ZonedDateTime?
My front-end send me a datetime string with an offset in a Post Mapping, such as : 2024-04-12T10:39:23+02:00
My goal is to map this datetime in my backend (java spring boot) and I want to keep the ...
1
vote
0
answers
53
views
Getting HijrahDate month name in Android
I am trying to display formatted Islamic month name using Java, currently I have the following code:
HijrahDate date = HijrahDate.from(LocalDate.of(2024, 4, 11));
System.out.println(DateTimeFormatter....
0
votes
2
answers
86
views
How to parse date/time string into a date/time where "local" time can be extracted
I have a Java (11) application that can receive data that includes date/time values in the format:
yyyy-mm-ddThh:mm:ss.sssZ example: 2024-04-01T17:33:58.713Z
I need to be able to parse these strings ...
1
vote
1
answer
44
views
How to convert "Tue Feb 27 2024 16:35:30 GMT+0800" String to ZonedDateTime type
I want to convert "Tue Feb 27 2024 16:35:30 GMT+0800" String to ZonedDateTime type
I use new ZonedDateTime.ofInstant(new Date("Tue Feb 27 2024 16:35:30 GMT+0800").toInstant(), ...
0
votes
1
answer
73
views
Format datetime in java based on locale
I want the date and time to be formatted based on the criteria(below objects) for each datetime component. And the separators between them should be taken based on locale. Is there way to achieve this ...
2
votes
2
answers
124
views
SimpleDateFormat gives a wrong date when input a wrong format date string
code is
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
Date date = format.parse("2024-03-01 09:20:46");
the date's value is Sun Dec 03 00:01:09 ...
-1
votes
2
answers
77
views
String dateTime = DateFormat.format("dd/MM/yyyy hh:mm aa", cal).toString(); [closed]
How do I fix an error? When I send a message, the date appears correctly, but when I receive a message, the date appears incorrectly. For example, 5 p.m., the date appears at 8 p.m. Here is a three-...
2
votes
3
answers
279
views
How to adjust the hours in working hours calendar
I am trying to add the working hours of the employee with the following scenario: let's say the current date is: 2012-05-20 15:00, and the employee's normal working hours are 08:00-16:00, I want to ...