android - Date object not returning correct time value -



android - Date object not returning correct time value -

i using below code current time in specific format , want print time stamp.

simpledateformat dateformat = new simpledateformat("mm-dd hh:mm:ss.ms"); string formatteddate = dateformat.format(new date()); date curdate = null; seek { curdate = dateformat.parse(formatteddate); } grab (parseexception e) { // todo auto-generated grab block e.printstacktrace(); } log.i(config.tag,"curdate...... "+curdate);

but when see logcat output "curdate....." showing "mon jul 13 04:11:51 edt 1970" in above statement minutes wrong. in android device, time showing "04:40 am".

i unable figure out why above method capturing "29" minutes delay.??

pl. allow me know proper way this. allow me know if missed something.

i suspect it's "ms" part of format string confusing things. think mean "ss" instead. also, given haven't got am/pm specifier, want 24-hour format instead of 12-hour:

simpledateformat dateformat = new simpledateformat("mm-dd hh:mm:ss.ss");

(do really not want year, way?)

android

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -