java - Change from hour minute second to second from string -


now,i have string string time= "200hour 0minute 0second" want track numbers in string , convert second..as above string..i want value 200*3600.. code:

    //change hour minute second public string changesecond(string time) {     string result;     int ind_hour=time.indexof("hour");     int ind_minute=time.indexof("minute");     int ind_second=time.indexof("second");      int hour=integer.parseint(time.substring(0, ind_hour));     int minute=integer.parseint(time.substring(ind_hour+1, ind_minute));;     int second=integer.parseint(time.substring(ind_minute+1, ind_second));      result=string.valueof(hour*3600+minute*60+second);      return result; } 

but when run changesecond(time).it don't work..how must do.

you should make changes following lines:

int hour=integer.parseint(time.substring(0, ind_hour)); int minute=integer.parseint(time.substring(ind_hour+5, ind_minute)); int second=integer.parseint(time.substring(ind_minute+7, ind_second)); 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -