Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I would like to get date of the monday week -3 with "talend code"
Exemple : we are on 2015-10-20. I would like to show these date : 2015-09-28 and 2015-10-19
the first date is monday of week -3 and the second date is monday of current week.
sorry for my poor english
thx
package routines;
import java.util.Date;
public class MyRoutine {
static int day_of_week;
static Date currentMonday;
public static Date getCurrentMonday(Date date) {
day_of_week=TalendDate.getPartOfDate("DAY_OF_WEEK", date);
if(day_of_week==1){
currentMonday= TalendDate.addDate(date, 1, "dd");
}else if(day_of_week==2){
currentMonday=date;
}else if(day_of_week==3){
currentMonday= TalendDate.addDate(date, -1, "dd");
}else if(day_of_week==4){
currentMonday= TalendDate.addDate(date, -2, "dd");
}else if(day_of_week==5){
currentMonday= TalendDate.addDate(date, -3, "dd");
}else if(day_of_week==6){
currentMonday= TalendDate.addDate(date, -4, "dd");
}else {
currentMonday= TalendDate.addDate(date, -5, "dd");
}
return currentMonday;
}
}