将数字转换为时间

 

int time = 3968;

int second = int.Parse((time % 60).ToString());
int minute = int.Parse((time / 60 % 60).ToString());
int hour = int.Parse((time / 60 / 60).ToString());
string sec = (second < 10) ? ("0" + second.ToString()) : second.ToString();
string min = (minute < 10) ? ("0" + minute.ToString()) : minute.ToString();
string hou = (hour < 10) ? ("0" + hour.ToString()) : hour.ToString();

string times = hou + ":" + min + ":" + sec;

 

eg:01:06:08

 

这样就将数字转换成时间了。

 

 

 

 

你可能感兴趣的:(String)