回答編集履歴
2
絶対値
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
LocalDateTime from, to; // 初期化済とする
|
8
8
|
|
9
|
-
boolean tenMinOrMore = from.until(to, ChronoUnit.MINUTES) >= 10L;
|
9
|
+
boolean tenMinOrMore = Math.abs(from.until(to, ChronoUnit.MINUTES)) >= 10L;
|
10
10
|
|
11
11
|
```
|
12
12
|
|
@@ -20,6 +20,6 @@
|
|
20
20
|
|
21
21
|
LocalDateTime from, to; // 初期化済とする
|
22
22
|
|
23
|
-
boolean tenMinOrMore = ChronoUnit.MINUTES.between(from, to) >= 10L;
|
23
|
+
boolean tenMinOrMore = Math.abs(ChronoUnit.MINUTES.between(from, to)) >= 10L;
|
24
24
|
|
25
25
|
```
|
1
コード
test
CHANGED
@@ -1 +1,25 @@
|
|
1
1
|
[untilメソッド](https://docs.oracle.com/javase/jp/8/docs/api/java/time/LocalDateTime.html#until-java.time.temporal.Temporal-java.time.temporal.TemporalUnit-)がまさにそれ
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
```java
|
6
|
+
|
7
|
+
LocalDateTime from, to; // 初期化済とする
|
8
|
+
|
9
|
+
boolean tenMinOrMore = from.until(to, ChronoUnit.MINUTES) >= 10L;
|
10
|
+
|
11
|
+
```
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
あるいはドキュメントの通り、`TemporalUnit#between`か
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
```java
|
20
|
+
|
21
|
+
LocalDateTime from, to; // 初期化済とする
|
22
|
+
|
23
|
+
boolean tenMinOrMore = ChronoUnit.MINUTES.between(from, to) >= 10L;
|
24
|
+
|
25
|
+
```
|