when i am print System.currentTimeMillis()
give me :
11-03 14:47:05.400: INFO/System.out(7579): date is :: 14475410111
What is the correct procedure to get entire date with time.?
To get current date and time in Android, You can use:
Calendar c = Calendar.getInstance();
System.out.println("Current time => "+c.getTime());
Current time => Thu Nov 03 15:00:45 GMT+05:30 2011
FYI, once you have this time in 'c' object, you can use SimpleDateFormat class to get date/time in desired format.
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Sring formattedDate = df.format(c.getTime()); // c is Calendar object
System.out.println("========> formatted date => "+formattedDate);
Output: ========> formatted date => 2011-11-03 15:13:37
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With