Questions tagged [chronounit]
7 questions
5
votes
3 answers
How to convert from long+TimeUnit to Duration?
I'm migrating some signatures from f(long dur, TimeUnit timeUnit) to f(Duration duration), and would like to implement the former with the latter.
Being on Java 8, I can't find any API to easily convert the long+TU to a Duration, the only idea that…

Adam Kotwasinski
- 4,377
- 3
- 17
- 40
1
vote
2 answers
ZonedDateTime handles only one side of daylight savings during hour difference calculation
I am trying to find the difference between 2 datetime which are in Adelaide timezone. The difference in hours is returned correctly in case of DST start but wrong for DST end.
As per the output below, in case of DST start, for 1st Oct 2023, the…

Ashik K
- 13
- 5
0
votes
3 answers
Get count day between to date Java
Hello i need to get count day between to date using ChronoUnit
this is my code :
Date madate = rfxobjet.getRv_rc_date();
Date date=java.util.Calendar.getInstance().getTime();
Date res=null;
int day =…

mehdi hanine
- 113
- 1
- 4
- 11
0
votes
1 answer
Finding the intersection between two date ranges in Java (programatically)
I would like to calculate the number of the overlapping days between two date ranges. The 2 pairs of date ranges are read from the console in the format: yyyy-mm-dd;
For example, if the two dates are…

Y.I
- 25
- 5
0
votes
1 answer
Python compute timeframe length between two dates
I'm looking for the module ChronoUnit
java.time.temporal.ChronoUnit
implementation in Python, found in Java 8.
The reason this modules is useful, is because it contains a procedure that computes the Days, Months, Years etc.. between to arbitrary…

Cristofor
- 2,077
- 2
- 15
- 23
-1
votes
1 answer
java chrono unit difference between year
i have below code to get difference between two years..
long yearsBetween = ChronoUnit.YEARS.between(
customDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(),
LocalDate.now());
my date value is as…

pappu_kutty
- 2,378
- 8
- 49
- 93
-2
votes
2 answers
Why ChronoUnit.HOURS.between() is NOT working?
I was trying to get the hours between two local dates. And I used the code below :
LocalDate startDate = LocalDate.of(2000, 4, 30);
long noOfHours = startDate.until(LocalTime.now(), ChronoUnit.HOURS);
…