时钟机制

时间:2018-11-17 22:33:19

标签: java timezone logic clock

我一直在尝试制作时区计算器,但从0h到24h却遇到问题,反之亦然。这是我的代码:

import java.util.Scanner; //this is for something else in the main method
import java.time.Clock;

public class TmzCalc extends Thread
{

public static void main(String args[])
{
//skipping some useless code
TmzCalc.hst(int hr); //the integer is declared inside main, and used by the 
hst method
}

public static void hst(int hr)
{
int x = hr - 10;
if(hr < 0){
   hr = 24;
};
     System.out.println("Honolulu-HST :: " + x);
}

现在是问题所在:如果我说hr是2,那么它将打印-8,而我实际希望打印的是16。谢谢大家!

0 个答案:

没有答案