Current date should add 12 hours more in android -
in application want add 12 hours current date , time,then have show in format "yyyy-mm-dd hh:mm:ss". wrote code unable add 12 hours. how can do? please help.
my code :
calendar cal = calendar.getinstance(); date date = cal.gettime(); string date1 = (new simpledateformat("yyyy-mm-dd hh:mm:ss")).format(date); m_tvtrackend.settext(date1);
the calendar
class has add
method can use add units.
calendar cal = calendar.getinstance(); cal.add(calendar.hour, 12); date date = cal.gettime(); string date1 = (new simpledateformat("yyyy-mm-dd hh:mm:ss")).format(date); m_tvtrackend.settext(date1);
Comments
Post a Comment