码迷,mamicode.com
首页 > 其他好文 > 详细

用if语句把24小时制转换成12小时制

时间:2015-12-02 20:37:57      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:

public class yunsuanfu {
    public static  void main(String[] arg){
        double t=2;
        int h=38;
        int m=100;
        int s=100;
    
        if(s>60){
            m=(s/60)+m;s=s%60;
        }
        if (m>60){
            h=(m/60)+h;m=m%60;
        }
        if(h>12){
         t=t+(0.5*(h/12));h=h%12;
        }
        System.out.println(t+"天"+h+"点"+m+"分"+s+"秒");
}
}

 

用if语句把24小时制转换成12小时制

标签:

原文地址:http://www.cnblogs.com/php111/p/5013783.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!