zipping day of week from date

One Star

zipping day of week from date

Hey there all you guru's,
I am rather new in Talend & coping with a problem... Hou can I extract the daynumber in a date (ex 1 for mon, 2 for tue, etc) I have done this with "calCurrent.get(java.util.Calendar.DAY_OF_WEEK);" in a javaFlex, but now I wnt it done in a tMap, like " Integer.parseInt(TalendDate.formatDate("dd", basicFlow.date)); ".... yet the string-parameter is evasive..... please help!
Thanxx!,
Eric
Community Manager

Re: zipping day of week from date

Hello Eric
Go to Repository-->Code-->Routines and create a new routine:
// template routine Java
package routines;
import java.util.Date;
import java.util.Calendar;
public class GetWeekDay {
static int day;
public static int getWeekDay(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
day = c.get(java.util.Calendar.DAY_OF_WEEK);
if (day == 1) { // means it is SATURDAY;
day = day + 6;
} else {
day = day - 1;
}
return day;
}
}

Then, call this routine on tMap:
GetWeekDay.getWeekDay(basicFlow.date)
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business