package com.mindprod.inauguration;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.TimeZone;

/**
 * Demonstrate how to display date and time with a custom mask.
 *
 * @author Roedy Green
 * @Version 1.2 2005-06-30
 */
public final class InaugurationCustom
    {
    // ------------------------------ FIELDS ------------------------------

    /**
     * mask for: Tuesday 2009/01/20 12:00:00 PM EST : Eastern Standard Time
     */
    private static final SimpleDateFormat SDF =
            new SimpleDateFormat( "EEEE yyyy/MM/dd hh:mm:ss aa zz : zzzzzz" );

    // --------------------------- main() method ---------------------------

    /**
     * Main method.
     *
     * @param args not used
     */
    public static void main( String[] args )
        {
        // inauguration day is Thursday 2009-01-20 noon Eastern Standard
        // Time. Same code automatically adjusts for DST in the summer.
        final int inaugYear = 2009;
        TimeZone est = TimeZone.getTimeZone( "America/New_York" );
        GregorianCalendar inauguration = new GregorianCalendar( est );
        inauguration.set( inaugYear, Calendar.JANUARY, 20, 12, 0, 0 );

        // set timezone
        SDF.setCalendar( inauguration );

        // Get display string in EST
        String dateString = SDF.format( inauguration.getTime() );
        System.out.println( dateString );
        }
    }