本文整理匯總了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);
}