java - trouble with local time -


i use these codes local time:

dateformat dateformat = new simpledateformat("yyyy/mm/dd hh:mm:ss"); calendar currenddate = calendar.getinstance(timezone.getdefault()); system.out.print("last update: "+dateformat.format(currenddate.gettime())); 

or:

dateformat dateformat = new simpledateformat("yyyy/mm/dd hh:mm:ss"); calendar currenddate = calendar.getinstance(gettimezone("gmt+3.5")); system.out.print("last update: "+dateformat.format(currenddate.gettime())); 

but non of them give local time, both giving me gmt problem?

note: using eclipse , android programming, codes above correctly work in java in android not!

instead of system.out.print() use textview show time

textview date = (textview) findviewbyid(r.id.gold_textview1); date.settext("last update: "+dateformat.format(currenddate.gettime())); 

please me find problem

try date currentdate = new date() instead of calendar object. system.out.print() call won't change. also, double check system make sure default timezone set correctly.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -