简体   繁体   English

如何设置1.5小时的时间间隔?

[英]how to set time interval of 1.5 hours?

In the following code the time interval is of 1 hour but I want a time interval of 1.5 hour.在以下代码中,时间间隔为 1 小时,但我想要 1.5 小时的时间间隔。 For example 8:30-10:00.例如 8:30-10:00。 What am I doing wrong?我究竟做错了什么? or is there any Java library which can help me set my desired time interval of 1.5 hour?或者是否有任何 Java 库可以帮助我将所需的时间间隔设置为 1.5 小时?

private static void createLectureTime()
{
    for (int i=8; i<16; i++)
    {           
        lectureTimings.add(i+":30"+" TO "+(i+1)+":00");             
    }
}

You can use Calendar class to solve this problem.Here is the code.您可以使用 Calendar 类来解决这个问题。代码如下。

long startTime = System.currentTimeMillis();
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(startTime);
calendar.add(Calendar.MINUTE, 90);
System.out.println(calendar.getTime());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM