/*
 * [InaugurationElapsed.java]
 *
 * Summary: calculate hours to next inauguration. Demonstrates use of GregorianCarlendar for elapsed time calculation.
 *
 * Copyright: (c) 2000-2017 Roedy Green, Canadian Mind Products, http://mindprod.com
 *
 * Licence: This software may be copied and used freely for any purpose but military.
 *          http://mindprod.com/contact/nonmil.html
 *
 * Requires: JDK 1.8+
 *
 * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/
 *
 * Version History:
 *  1.2 2006-03-05 reformat with IntelliJ, add Javadoc.
 *  1.3 2009-01-20 change to Obama
 */
package com.mindprod.inauguration;

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

import static java.lang.System.*;

/**
 * calculate hours to next inauguration. Demonstrates use of GregorianCarlendar for elapsed time calculation.
 *
 * @author Roedy Green, Canadian Mind Products
 * @version 1.2 2005-06-30
 * @since 2000
 */
public final class InaugurationElapsed
    {
    /**
     * 3,600,000 the number of milliseconds in an hour
     * Cannot use TimeUnit in Java 1.1
     */
    private static final int MILLISECONDS_PER_HOUR = 60 * 60 * 1000;

    /**
     * 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 = 2017;
        TimeZone est = TimeZone.getTimeZone( "America/New_York" );
        GregorianCalendar inauguration = new GregorianCalendar( est );
        inauguration.set( inaugYear, Calendar.JANUARY, 20, 12, 0 );
        // now is current time, using default TimeZone
        GregorianCalendar now = new GregorianCalendar();
        // milliseconds since 1970-01-01
        long epochInauguration = inauguration.getTime().getTime();
        long epochNow = now.getTime().getTime();
        double hours = ( double ) ( epochInauguration - epochNow ) / MILLISECONDS_PER_HOUR;
        out.println( hours + " hours until the inauguration." );
        }
    }