2
How do I know how many weekdays of specific types (for example, only Mondays, Tuesdays and Wednesdays) exist between two dates in Java?
For example, from date 01/12 to 30/12, how many segundas, terças e quartas
exist among them?
2
How do I know how many weekdays of specific types (for example, only Mondays, Tuesdays and Wednesdays) exist between two dates in Java?
For example, from date 01/12 to 30/12, how many segundas, terças e quartas
exist among them?
Browser other questions tagged java
You are not signed in. Login or sign up in order to post.
Using a lib with for example joda-time, you can do as in this post here, https://stackoverflow.com/questions/3802893/number-of-days-between-two-dates-in-joda-time
– LR10
You want to count the days between two dates, but ignoring certain days of the week in the count, would be this?
– gato
He wants to count how many "Mondays, Tuesdays and Wednesdays" there are from a date D to a date D+N.
– Gustavo Cinque
that, I want to count how many Mondays, Tuesdays and Wednesdays exist from an X date to a Y date
– felipe.rce
@LR10, the link you passed talks only about counting days between two dates, without taking into account the detail I mentioned, (I edited my reply)...
– felipe.rce
@Felipe.rce See if my edition agrees with what you’re wanting.
– Pablo Almeida
See this example in Ideone @Felipe.rce. Using only Java.
– Gustavo Cinque
@Gustavocinque is exactly what I wanted!
– felipe.rce
Localdate startDate = new Localdate(2017, 11, 01); Localdate endDate = new Localdate(2017, 11, 30) Days days = Days.daysBetween(startDate, endDate). getDays() ;
– LR10
You can do a for in days and take getDayOfWeek() for example and count the days. It’s a suggestion. As here https://stackoverflow.com/questions/15338196/joda-time-get-week-days
– LR10
That’s right @LR10, came to see the example I put?
– Gustavo Cinque
I’m waiting to reopen (I don’t know why they closed, since it was edited before it was closed) so I can accept the answer
– felipe.rce