Hi Experts,
I am unable to understand the below UDF. Can anyone help me with some example:
The input is something like YEARWEEK i.e. 201449 or 201501 which is splitted as 2014 or 2015 and 49 or 01 using Substring function.
Locale loc = new Locale("en","us");
Calendar cal1 = Calendar.getInstance(loc);
cal1.setLenient(true);
cal1.set(Calendar.WEEK_OF_YEAR, week);
cal1.set(Calendar.YEAR, year);
cal1.set(Calendar.DAY_OF_WEEK,2);
cal1.setMinimalDaysInFirstWeek(1);
int data = cal1.get(Calendar.DATE);
String fin = Integer.toString(data);
String res = String.format("%1$2s",fin).replaceAll(" ","0")+""+(String.format("%1$2s",(cal1.get(Calendar.MONTH)+1)).replaceAll(" ","0"))+""+cal1.get(Calendar.YEAR);
String sample = res;
SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyy");
Date date = new Date();
try
{
date = sdf.parse(sample);
}
catch (java.text.ParseException e)
{
}
Calendar cal2 = Calendar.getInstance();
cal2.setLenient(true);
cal2.setMinimalDaysInFirstWeek(4);
cal2.setTime(date);
int res1 = cal2.get(Calendar.WEEK_OF_YEAR);
String finalweek = Integer.toString(res1);
return String.format("%1$2s",finalweek).replaceAll(" ","0");
Thanks,
Shaibayan