I just want to (filter/sort/remove) the weekends(Saturday and Sunday) in the list and store them in a new list in java. i). The class Name is Holiday, it holds only one variable named holiday date.
ii). And I have a table named Holiday, in this table I have data stored (Holidays list for 2022), totally I have 17 records in a table.
iii). That table data record can be fetched as a list.
iv). Have to find, if the employee takes a leave, that comes in holiday.
v). Now, compare an employee holiday with the Holidays list for 2022(17 records)
vi)If employee leave is the same as the date of the holiday list means I want to remove it and filter other normal working days & Store the dates in new array list.
vii) I just check the what diff between the two date formats.
viii) I am new to Java 8 concepts so. now only I start to learn java 8 that's why face this problem I just copy the code from this link and alternate it stackoverflow.com/questions/58134699/…
String from="28/04/2022",;
String to="28/07/2022",;
Date d_from = new SimpleDateFormat("yyyy-MM-dd").parse(from);
Date d_to = new SimpleDateFormat("yyyy-MM-dd").parse(to);
//System.out.println(d_from.getTime());
long t1=d_from.getTime();
long t2=d_to.getTime();
SimpleDateFormat f=new SimpleDateFormat("dd/MM/yyyy");
List<Hoilday> Hoilday_list = new ArrayList<>();
Map<String, Object> paramMap = new HashMap<>();
StringBuilder sb = new StringBuilder();
String sql = "";
sb.append("select holidayDate as hoildayDate from hoildays ");
sql = sb.toString();
Hoilday_list = namedParameter.query(sql, paramMap, new BeanPropertyRowMapper<>(Hoilday.class));
if(t1<t2)
{
//1 = 1000
for(long i=t1;i<=t2;i+=86400000)
{
String allDates = f.format(i);
List<String> list = new ArrayList<String>();
list.add(allDates);
for(Hoilday Hoildays: Hoilday_list) {
List<Hoilday> result = Hoilday_list.stream()
.filter(app1 -> list.stream()
.noneMatch(app2 -> Hoildays.getHoildayDate().equals(list)))
.collect(Collectors.toList());
log.info(result);
In Advance Thank you for solving the question.