About Me

My photo
Talk to me... you will know

Thursday, January 12, 2012

Appian

I have been working on the appian api and trust me its very different from what i expected... the no of hassles faced are so much that for just shifting from 1 version to other i had to do a POC.. It was worth it.. :)





package com.trial;


import com.ibm.icu.text.DateFormatSymbols;
import com.ibm.icu.text.SimpleDateFormat;
import com.ibm.icu.util.Calendar;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;


/**
 *This program helps to find out the difference in calendar implementations of Appian 5.0 and Appian 6.0
 *@author ajo.koshy
 *@version 1.0
 *The only requirements are 4 jar files :
 *a) appian-asi
 *b) appian-util
 *c) appian-globalization
 *d) icu4j-4.0.1
 * */
public class TrialExec {
/**
* @throws None
* @author ajo.koshy
* */
public static void main(String args[]){

String ans="";
Calendar cal = Calendar.getInstance(Locale.UK);// Use Locale.US for different answer
SimpleDateFormat dtf = new SimpleDateFormat("MM/dd/yy", Locale.UK);// Use Locale.US for different answer
DateFormatSymbols symbols = dtf.getDateFormatSymbols();
String[] shortWeekdays = symbols.getShortWeekdays();
List<String> weekdayInitials = new ArrayList<String>();
int firstDayOfWeek = cal.getFirstDayOfWeek();
cal.set(2012, 0, 1);
int blankSpaces = cal.get(7) - firstDayOfWeek;
int newBlankSpaces = getLeadingBlankSpaces(cal);


for (int i = firstDayOfWeek; i < shortWeekdays.length; i++) {
/*if (shortWeekdays[i].length() > 0) {
 
}*/
weekdayInitials.add(Character.toString(shortWeekdays[i].charAt(0)));
}
 
for (int i = 0; i < firstDayOfWeek; i++) {
if (shortWeekdays[i].length() > 0) {
weekdayInitials.add(Character.toString(shortWeekdays[i].charAt(0)));
}
}



for(int i=0;i<weekdayInitials.size();i++)
{
ans=ans+" "+weekdayInitials.get(i);
}

System.out.println(ans);
System.out.println(cal.getTime());
System.out.println("blankspaces are = "+blankSpaces);
System.out.println("now blankspaces are = "+newBlankSpaces);

}

private static int getLeadingBlankSpaces(Calendar firstDayOfTargetMonthAndYear) {
/**
* @author ajo.koshy
* @param Calendar Object
* */

int firstDayOfWeek = firstDayOfTargetMonthAndYear.getFirstDayOfWeek();
int daysPerWeek = firstDayOfTargetMonthAndYear.getMaximum(7);
int dayOfWeek = firstDayOfTargetMonthAndYear.get(7);
return (daysPerWeek + (dayOfWeek - firstDayOfWeek)) % daysPerWeek;

}
/**
* @return nothing.. but prints values that differ with the locale
* */

}

There was an error in this gadget