package com.mindprod.example;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

/**
 * Display Today's date
 * <p/>
 * composed with IntelliJ IDEA
 *
 * @author Roedy Green, Canadian Mind Products
 * @version 1.0, 2006-03-02
 */
public final class TestToday
    {
// ------------------------------ FIELDS ------------------------------

    /**
     * ISO format YYYY-MM-DD, could use other masks.
     */
    private static final SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd" );

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

    /**
     * Display current date e.g. 2006-01-22
     *
     * @param args not used
     */
    public static void main( String[] args )
        {
        // we must pick a timezone since at any given instant,
        // part of the world is on Sunday and part on is on Monday,
        // part on the 22 and part on the 23.

        // if wanted UTC
        // TimeZone utc = TimeZone.getTimeZone( "UTC" );

        // if wanted Eastern standard elapsedTime
        // TimeZone est = TimeZone.getTimeZone( "America/New_York" );

        // if wanted user's local timezone
        TimeZone local = TimeZone.getDefault();

        sdf.setTimeZone( local );

        // new Date() gets current date/elapsedTime
        String dateString = sdf.format( new Date() );

        // display the date YYYY-MM-DD
        System.out.println( dateString );

        // display TimeZone
        String timeZoneName = local.getDisplayName();
        System.out.println( timeZoneName );
        }
    }