package org.jcon.test;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.text.DateFormat;

/**
 * java org.jcon.test.TestTime
 */
public class TestTime {

//---------- Initialization ------------------------------
public static void main(String args[]) {

GregorianCalendar calendar = new GregorianCalendar();

print("HOUR_OF_DAY = " + calendar.get(Calendar.HOUR_OF_DAY));
print("MINUTE = " + calendar.get(Calendar.MINUTE));
print("SECOND = " + calendar.get(Calendar.SECOND));

//print("getTimeInMillis = " + calendar.getTimeInMillis() );

print("currentTimeMillis " + System.currentTimeMillis());
print("getTimePoint() = " + getTimePoint());

Date now = new Date();
print("\nDate: " + now);

print(DateFormat.getDateInstance().format(now));
print(createCurrentDateTime());
}
//---------- Public Methods ------------------------------
public static String createCurrentDateTime() {
    Date now = new Date();
    String text = "";
    text += (now.getMonth() + 1) + "/"; // 0 based
    text += now.getDate() + "/"; // Day of month
    text += (now.getYear() + 1900) + " ";
    text += now.getHours() + ":";
    text += now.getMinutes() + ":";
    text += now.getSeconds() + "";
    return text;
}
//---------- Private Methods -----------------------------
// Returns currentTimeMillis() formatted to "999.99"
private static String getTimePoint() {
    String time = String.valueOf(System.currentTimeMillis());
    time = time.substring(time.length() - 6);
    return time.substring(0, 3) + "." + time.substring(3, 5);
}
//--- Std
private static void print(String text) {
    System.out.println(text);
}

}
