package com.mindprod.example;

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

/**
 * Display Today's date in Zulu format.
 * <p/>
 * composed with IntelliJ IDEA
 *
 * @author Roedy Green, Canadian Mind Products
 * @version 1.0, 2008-06-21
 */
public final class TestZulu
    {
    // ------------------------------ FIELDS ------------------------------

    /**
     * Zulu format mask 2008-06-22T14:51:18.62Z
     */
    private static final SimpleDateFormat SDF =
            new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" );

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

    /**
     * Display current Zulu/UTC military time,
     * e.g. 2008-06-22T14:51:18.62Z
     *
     * @param args not used
     */
    public static void main( String[] args )
        {
        // Zulu is UTC 24-hour time, no DST.
        final TimeZone utc = TimeZone.getTimeZone( "UTC" );
        SDF.setTimeZone( utc );
        final String milliformat = SDF.format( new Date() );
        // convert from milliseconds to centiseconds
        // by chopping off last digit
        final String zulu = milliformat.substring( 0, 22 ) + 'Z';
        System.out.println( zulu );
        }
    }