android - Check local time in if-statement -
android - Check local time in if-statement -
i managed local time, want utilize in if statement this:
calendar cal = calendar.getinstance(timezone.gettimezone("gmt+1:00")); date currentlocaltime = cal.gettime(); dateformat date = new simpledateformat("hh:mm"); // can seconds adding "...:ss" date.settimezone(timezone.gettimezone("gmt+1:00")); string localtime = date.format(currentlocaltime); log.w(localtime, "1"); if (localtime == "12:11") { log.w("yes", "this is"); } else { log.w("jhlgsaljfd", "kajfhsd"); }
however, not working, how check local time in if-else statement?
try equals
instead ==
, should be:
if (localtime.equals("12:11")){ log.w("yes", "this is"); } else { log.w("jhlgsaljfd", "kajfhsd"); }
android
Comments
Post a Comment