« first day (4317 days earlier)      last day (627 days later) » 

12:00 AM
How often I found where I should be going only by setting out for somewhere else. -- R. Buckminster Fuller (source)
 
 
7 hours later…
USM
6:51 AM
Hey Guys
we have to find the previous date from last week of today's system date
say , today is 17th Aug and specific date is 11th Aug then match fail
and today is 18th Aug and specific date is 17th Aug then match PASS
how to handle this in Java?
 
7:39 AM
you mean subtract 7 days?
 
USM
8:05 AM
yes 7 days
and it can be 7 , 14 , 28 etc..
no end date , even if the specified date is last year , we need to find if they belong to previous week
 
8:29 AM
that is different of what you just said
> we have to find the previous date from last week of today's system date
this is: today - 7 days
> we need to find if they belong to previous week
this is: week(target) == week(today - 7 days)
 
9:11 AM
the java time package has a functionality to get the week number.
use it
or use Wietlol's approach. Either way works
✌ out
 
my approach uses the week number
kind of
at least java.time
but you might want to get threeten.extra (extensions to java.time) to get the YearWeek class, which also accounts for year differences
 
USM
week (target) is the java.time method?
 
not really
but there must be some way to get the YearWeek object of a particular LocalDate
 
you have to be careful though. Dependent of the locale, the week is different here or there. This is because some countries starting their weeks on sunday instead of monday.
Had to provide a separate solution for US based deployments.
 
 
12 hours later…
9:24 PM
picks nose
 

« first day (4317 days earlier)      last day (627 days later) »