Using the Calendar
Hi I'm using the last version of the Sun Java Wirelless Toolkit (2.5).
I am writing an application and I need to get the system date and time.
I have tried with this:
calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT-05:00"));
calendar.setTime(new Date());
// to convert the current date to an String
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
int day = calendar.get(Calendar.DATE);
date = (month<10? "0": "")+ month+"/"+(day<10? "0": "") + day + "/" + (year<10? "0": "")+year;
// to convert the current time to an String
String[] AMPM = {"AM", "PM"};
int hour = calendar.get(Calendar.HOUR);
int minute = calendar.get(Calendar.MINUTE);
String am_pm = (AMPM[calendar.get(Calendar.AM_PM)]);
time = (hour + ":" + minute + am_pm);
but this code give me the time but one hour less.
Can someone send me a code that works or figure out what happen with this ?

