答案家

 找回密码
 立即注册
查看: 750|回复: 0

java编程题目:当前时间

[复制链接]

1万

主题

1万

帖子

80万

积分

校长

Rank: 9Rank: 9Rank: 9

积分
809492
发表于 2016-12-24 15:12:30 | 显示全部楼层 |阅读模式
package nameyu;import java.util.Scanner;public class Test {
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner input=new Scanner(System.in);
        System.out.print("Enter the time zone offset to GMT :");
        int GMT =input.nextInt();
        long totalMilliseconds=System.currentTimeMillis();
        long totalSeconds=totalMilliseconds/1000;
        long currentSecond=totalSeconds%60;
        long totalMinutes=totalSeconds/60;
        long currentMinutes=totalSeconds%60;
        long totalHours=totalMinutes/60;
        long currentHours=totalHours%24;
        System.out.println("Current time is"+(currentHours+GMT)+":"+currentMinutes+":"+currentSecond);
        }

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

CopyRight(c)2016 www.daanjia.com All Rights Reserved. 本站部份资源由网友发布上传提供,如果侵犯了您的版权,请来信告知,我们将在5个工作日内处理。
快速回复 返回顶部 返回列表