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
Post a Comment