Java simple Timestamp to Date conversion Java simple Timestamp to Date conversion unix unix

Java simple Timestamp to Date conversion


This works:

final Calendar cal = Calendar.getInstance();cal.setTimeInMillis(System.currentTimeMillis());Date date = cal.getTime();mHour = date.getHours();mMinute = date.getMinutes();


Just use the Java Calendar class.

Calendar c = new GregorianCalendar();  // This creates a Calendar instance with the current timemHour = c.get(Calendar.HOUR);mMinute = c.get(Calendar.MINUTE);

Also note that your Android emulator will return times in GMT for the current time. I advise testing this type of code on a real device.


Take a look of this.

Hope this is wat you need.

Android Simple Date Format

Good Luck!!