-3
I have two dates in milliseconds.
I need to recover every day of that period to make an insert in the database. I thought I’d do one for each day of that period, but I have no idea how to do it!
-3
I have two dates in milliseconds.
I need to recover every day of that period to make an insert in the database. I thought I’d do one for each day of that period, but I have no idea how to do it!
0
You can do this by using the API from java 8:
long a = ...;
long b = ...;
Instant ia = Instant.ofEpochMilli(a);
Instant ib = Instant.ofEpochMilli(b);
LocalDate lda = LocalDateTime.ofInstant(ia, ZoneId.of("Z")).toLocalDate();
LocalDate ldb = LocalDateTime.ofInstant(ib, ZoneId.of("Z")).toLocalDate();
List<LocalDate> dates = new ArrayList<>();
for (LocalDate ld = lda; !ld.isAfter(ldb); ld = ld.plusDays(1)) {
dates.add(ld);
}
See more about this in that other question.
Browser other questions tagged java android datetime date
You are not signed in. Login or sign up in order to post.
These dates are what? Values
long
obtained bySystem.currentTimeMillis()
?– Victor Stafusa