本文整理汇总了Java中java.time.LocalTime.minusMinutes方法的典型用法代码示例。如果您正苦于以下问题:Java LocalTime.minusMinutes方法的具体用法?Java LocalTime.minusMinutes怎么用?Java LocalTime.minusMinutes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.LocalTime
的用法示例。
在下文中一共展示了LocalTime.minusMinutes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_minusMinutes_one
import java.time.LocalTime; //导入方法依赖的package包/类
@Test
public void test_minusMinutes_one() {
LocalTime t = LocalTime.MIDNIGHT;
int hour = 0;
int min = 0;
for (int i = 0; i < 70; i++) {
t = t.minusMinutes(1);
min--;
if (min == -1) {
hour--;
min = 59;
if (hour == -1) {
hour = 23;
}
}
assertEquals(t.getHour(), hour);
assertEquals(t.getMinute(), min);
}
}
示例2: test_minusMinutes_fromZero
import java.time.LocalTime; //导入方法依赖的package包/类
@Test
public void test_minusMinutes_fromZero() {
LocalTime base = LocalTime.MIDNIGHT;
int hour = 22;
int min = 49;
for (int i = 70; i > -70; i--) {
LocalTime t = base.minusMinutes(i);
min++;
if (min == 60) {
hour++;
min = 0;
if (hour == 24) {
hour = 0;
}
}
assertEquals(t.getHour(), hour);
assertEquals(t.getMinute(), min);
}
}
示例3: main
import java.time.LocalTime; //导入方法依赖的package包/类
public static void main(String[] args) {
LocalTime movieStartTime = LocalTime.parse("21:00:00");
int commuteMin = 35;
LocalTime shreyaStartTime = movieStartTime.minusMinutes(commuteMin);
System.out.println("Start by" + shreyaStartTime + " from the office");
// second example
int worldRecord = 10;
LocalTime raceStartTime = LocalTime.of(8, 10, 55);
System.out.println("raceStartTime: " + raceStartTime);
LocalTime raceEndTime = LocalTime.of(8, 11, 11);
System.out.println("raceEndTime: " + raceEndTime);
System.out.println("raceEndTime plus 10 seconds: " + raceStartTime.plusSeconds(worldRecord));
if (raceStartTime.plusSeconds(worldRecord).isAfter(raceEndTime)) {
System.out.println("New world record");
} else {
System.out.println("Try harder");
}
// whith
LocalTime startTime = LocalTime.of(5, 7, 9);
if (startTime.getMinute() < 30) {
startTime = startTime.withMinute(0);
}
System.out.println(startTime);
}