Hey guys,
I am trying to create a simple java program that prints out the date that was submitted. I started playing around and noticed that the Calendar class prints exactly what I want. However. my program has to be printed showing GMT time.
My output has to be in the following format:
However, no matter how much I set the time zone to GMT, the program still outputs this:
The date you entered is: Thu Mar 25 00:00:00 GMT 2003
I dont understand why it prints BOT, when even the debugger shows me that the variable has a time zone of GMT. Here is my code:Thu Aug 29 03:04:01 BOT 2013
import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; public class DatePrinter { public static void main(String[] args) { TimeZone time = TimeZone.getTimeZone("GMT"); //Date cal = Calendar.getInstance(time).getTime(); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); System.out.println(cal.getTime()); } }
What am I doing wrong?
Thank you.