*/
public static void main(String[] args) throws JAXBException {
Calendar cal = Calendar.getInstance();
TimeZone timeZone = TimeZone.getDefault();
cal.setTimeZone(timeZone);
TradingCalendarFactoryBean bean = new TradingCalendarFactoryBean();
bean.setName("Example!");
bean.setDescription("An example bean");
bean.setTimeZoneId(timeZone.getID());
cal.set(2000, 11, 31, 23, 0, 0);
bean.setStartDate(cal.getTime());
cal.set(2100, 11, 31, 0, 0, 0);
bean.setEndDate(cal.getTime());
Set<BareDate> closingDays = new HashSet<BareDate>();
closingDays.add(new BareDate(2012, 12, 25));
closingDays.add(new BareDate(2012, 12, 31));
closingDays.add(new BareDate(2011, 1, 1));
bean.setClosingDays(closingDays);
Set<WeekTradingDay> weekTradingDays = new HashSet<WeekTradingDay>();
TradingPeriodBean tpBeanUnique = new TradingPeriodBean();
tpBeanUnique.setStartHour(10);
tpBeanUnique.setStartMinute(0);
tpBeanUnique.setEndHour(22);
tpBeanUnique.setEndMinute(30);
TradingPeriodBean tpBeanMorning = new TradingPeriodBean();
tpBeanMorning.setStartHour(10);
tpBeanMorning.setStartMinute(0);
tpBeanMorning.setEndHour(13);
tpBeanMorning.setEndMinute(30);
TradingPeriodBean tpBeanAfternoon = new TradingPeriodBean();
tpBeanAfternoon.setStartHour(14);
tpBeanAfternoon.setStartMinute(0);
tpBeanAfternoon.setEndHour(23);
tpBeanAfternoon.setEndMinute(30);
TradingDayBean tdBean1 = new TradingDayBean();
tdBean1.setTradingPeriods(new TradingPeriodBean[] { tpBeanUnique });
TradingDayBean tdBean2 = new TradingDayBean();
tdBean2.setTradingPeriods(new TradingPeriodBean[] { tpBeanMorning, tpBeanAfternoon });
weekTradingDays.add(new WeekTradingDay(Calendar.MONDAY, tdBean1));
weekTradingDays.add(new WeekTradingDay(Calendar.TUESDAY, tdBean1));
weekTradingDays.add(new WeekTradingDay(Calendar.WEDNESDAY, tdBean2));
weekTradingDays.add(new WeekTradingDay(Calendar.THURSDAY, tdBean1));
weekTradingDays.add(new WeekTradingDay(Calendar.FRIDAY, tdBean1));
bean.setWeekTradingDays(weekTradingDays);
Set<SpecificTradingDay> specialTradingDays = new HashSet<SpecificTradingDay>();
TradingDayBean stdBean1 = new TradingDayBean();
stdBean1.setTradingPeriods(new TradingPeriodBean[] { tpBeanMorning });
specialTradingDays.add(new SpecificTradingDay("20121224", stdBean1));
bean.setSpecialTradingDays(specialTradingDays);
bean.setIncludeAfterHours(true);
bean.setExchanges(new String[] { "GLOBEX", "CBOT" } );
JAXBContext context = JAXBContext.newInstance(TradingCalendarFactoryBean.class, WeekTradingDay.class, SpecificTradingDay.class);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
m.marshal(bean, new File("sample/output.xml"));