0

I Make a J2ME Application and I just want to print the system date and time, and when I search I found this class that used for that purpose, but I didn't find it in J2ME to use it.

How can I do that?

gnat
  • 6,213
  • 108
  • 53
  • 73
Amira Elsayed Ismail
  • 9,216
  • 30
  • 92
  • 175
  • use String parsing tools, as suggested in the answer here: http://stackoverflow.com/questions/9531582/how-to-convert-12-hours-time-to-24-hours-time-in-j2me (as the normal Java utility SimpleDateFormat does not exist in the [midp 2 API](http://docs.oracle.com/javame/config/cldc/ref-impl/midp2.0/jsr118/index.html "midp 2 API javadocs")). – gnat May 03 '12 at 09:57

1 Answers1

3

Is this enough for what you need?


    Calendar cal = Calendar.getInstance();
    StringBuffer date = new StringBuffer();
    StringBuffer time = new StringBuffer();

    date.append(cal.get(Calendar.DATE)).append('/');
    date.append(cal.get(Calendar.MONTH) +1).append('/');
    date.append(cal.get(Calendar.YEAR));
    time.append(cal.get(Calendar.HOUR_OF_DAY)).append(':');
    time.append(cal.get(Calendar.MINUTE)).append(':');
    time.append(cal.get(Calendar.SECOND));

Telmo Pimentel Mota
  • 4,033
  • 16
  • 22