Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
//get the date as a date.
Date date = TalendDate.parseDate("yyyyMMdd","20101231");
//get month as a number NOTE: this starts at 0 for January and goes to 11 for December.
int month = TalendDate.getPartOfDate("MONTH",date);
//get week of year*
int weekOfYear = TalendDate.getPartOfDate("WEEK_OF_YEAR",date);
//get our desired calendar year, 26 is chosen arbitrarily since it's simply the halfway point of a year.
int calendarWeek = month==11 && weekOfYear < 26 ? weekOfYear+52 : weekOfYear;
//get fiscal week.
int fiscalWeek = calendarWeek > 26 && month>=6 ? calendarWeek-26 : calendarWeek+26;
connecting to socket on port 4063
connected
month = 5
various week stuff for date: 20100630
Week of Year
Calendar: 27
Fiscal: 53
month = 6
various week stuff for date: 20100701
Week of Year
Calendar: 27
Fiscal: 1
month = 11
various week stuff for date: 20101226
Week of Year
Calendar: 53
Fiscal: 27
month = 11
various week stuff for date: 20101231
Week of Year
Calendar: 53
Fiscal: 27
month = 0
various week stuff for date: 20100101
Week of Year
Calendar: 1
Fiscal: 27
disconnected
//get the date as a date.
Date date = TalendDate.parseDate("yyyyMMdd","20101231");
//get month as a number NOTE: this starts at 0 for January and goes to 11 for December.
int month = TalendDate.getPartOfDate("MONTH",date);
//get week of year*
int weekOfYear = TalendDate.getPartOfDate("WEEK_OF_YEAR",date);
//get our desired calendar year, 26 is chosen arbitrarily since it's simply the halfway point of a year.
int calendarWeek = month==11 && weekOfYear < 26 ? weekOfYear+52 : weekOfYear;
//get fiscal week.
int fiscalWeek = calendarWeek > 26 && month>=6 ? calendarWeek-26 : calendarWeek+26;
connecting to socket on port 4063
connected
month = 5
various week stuff for date: 20100630
Week of Year
Calendar: 27
Fiscal: 53
month = 6
various week stuff for date: 20100701
Week of Year
Calendar: 27
Fiscal: 1
month = 11
various week stuff for date: 20101226
Week of Year
Calendar: 53
Fiscal: 27
month = 11
various week stuff for date: 20101231
Week of Year
Calendar: 53
Fiscal: 27
month = 0
various week stuff for date: 20100101
Week of Year
Calendar: 1
Fiscal: 27
disconnected