Anul 3 Semestrul 2

This commit is contained in:
2025-07-03 20:56:38 +03:00
parent 184f3bd92e
commit 3b7fb85767
269 changed files with 20955 additions and 0 deletions
@@ -0,0 +1,37 @@
package curent;
import validation.ValidationException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.time.LocalDate;
import static java.time.temporal.ChronoUnit.DAYS;
public class Curent {
/**
* @return the current week from the starting of university
*/
public static int getCurrentWeek(){
LocalDate startDate = Curent.getStartDate();
LocalDate today = LocalDate.now();
long days = DAYS.between(startDate, today);
double diff = Math.ceil((double)days/7);
return (int)diff;
}
/**
* @return the date when university have started
*/
public static LocalDate getStartDate() {
String filename = "fisiere/DataInceput.txt";
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(filename))) {
String line = bufferedReader.readLine();
String[] words = line.split(",");
return LocalDate.of(Integer.parseInt(words[0]), Integer.parseInt(words[1]), Integer.parseInt(words[2]));
} catch (IOException exception) {
throw new ValidationException(exception.getMessage());
}
}
}