本文整理匯總了Java中java.time.LocalTime.withMinute方法的典型用法代碼示例。如果您正苦於以下問題:Java LocalTime.withMinute方法的具體用法?Java LocalTime.withMinute怎麽用?Java LocalTime.withMinute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.time.LocalTime
的用法示例。
在下文中一共展示了LocalTime.withMinute方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
示例2: test_withMinute_normal
import java.time.LocalTime; //導入方法依賴的package包/類
@Test
public void test_withMinute_normal() {
LocalTime t = TEST_12_30_40_987654321;
for (int i = 0; i < 60; i++) {
t = t.withMinute(i);
assertEquals(t.getMinute(), i);
}
}