Exo1 / Refactor vers DateUtils
This commit is contained in:
parent
0214446765
commit
9c7885aa0e
7 changed files with 29 additions and 15 deletions
BIN
.DS_Store
vendored
BIN
.DS_Store
vendored
Binary file not shown.
BIN
carApp/.DS_Store
vendored
BIN
carApp/.DS_Store
vendored
Binary file not shown.
BIN
junit5-jupiter-starter-gradle/.DS_Store
vendored
BIN
junit5-jupiter-starter-gradle/.DS_Store
vendored
Binary file not shown.
BIN
tutoRefactoring/.DS_Store
vendored
BIN
tutoRefactoring/.DS_Store
vendored
Binary file not shown.
BIN
tutoRefactoring/src/.DS_Store
vendored
BIN
tutoRefactoring/src/.DS_Store
vendored
Binary file not shown.
14
tutoRefactoring/src/main/java/DateUtils.java
Normal file
14
tutoRefactoring/src/main/java/DateUtils.java
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import java.time.LocalDate;
|
||||
|
||||
public class DateUtils {
|
||||
public static boolean isNowBetween(LocalDate startingDate, LocalDate endingDate) {
|
||||
LocalDate now = LocalDate.now();
|
||||
return isaBoolean(startingDate, endingDate, now);
|
||||
}
|
||||
|
||||
private static boolean isaBoolean(LocalDate startingDate, LocalDate endingDate, LocalDate now) {
|
||||
return now.isAfter(startingDate)
|
||||
&&
|
||||
now.isBefore(endingDate);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,33 +1,33 @@
|
|||
import java.time.LocalDate;
|
||||
import java.util.Locale;
|
||||
|
||||
public class SimpleClass {
|
||||
|
||||
public SimpleClass() {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new SimpleClass().add(1, 2);
|
||||
|
||||
System.out.println("Hello world");
|
||||
}
|
||||
|
||||
public static boolean isNowBetween(LocalDate startingDate, LocalDate endingDate) {
|
||||
LocalDate now = LocalDate.now();
|
||||
return (now.isAfter(startingDate)
|
||||
&&
|
||||
now.isBefore(endingDate)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Additionne a et b
|
||||
* @param a - premier paramètre
|
||||
* @param b - second paramètre
|
||||
* @return
|
||||
*/
|
||||
public int someAdditionMethod(int a, int b) {
|
||||
public int add(int a, int b) {
|
||||
return a + b ;
|
||||
}
|
||||
|
||||
public static boolean isNowBetween (LocalDate startingDate, LocalDate endingDate) {
|
||||
return ( LocalDate.now().isAfter(startingDate)
|
||||
&&
|
||||
LocalDate.now().isBefore(endingDate)
|
||||
);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new SimpleClass().someAdditionMethod(1,2);
|
||||
|
||||
System.out.println("Hello world");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue