the first working version #2

Merged
Petr merged 15 commits from develop into master 2025-02-19 07:56:27 +00:00
Showing only changes of commit 6dc8976eda - Show all commits

@ -1,5 +1,6 @@
package com.example.nto.utils;
import com.example.nto.config.ObjectStorageConfig;
import lombok.experimental.UtilityClass;
import java.time.*;
@ -14,6 +15,8 @@ public class Utils {
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd");
private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("HH:mm:ss");
private static final ObjectStorageConfig storageConfig = new ObjectStorageConfig();
public static String profileFileName(long userId) {
return "profile--" + userId;
}
@ -24,12 +27,17 @@ public class Utils {
public static String nowTime(DataFormatType type) {
switch (type) {
case DATE_TIME: return LocalDateTime.now().format(DATE_TIME_FORMAT);
case DATE: return LocalDateTime.now().format(DATE_FORMAT);
case TIME: return LocalDateTime.now().format(TIME_FORMAT);
default: return "Произошла ошибка при форматировании даты или времени.";
case DATE_TIME:
return LocalDateTime.now().format(DATE_TIME_FORMAT);
case DATE:
return LocalDateTime.now().format(DATE_FORMAT);
case TIME:
return LocalDateTime.now().format(TIME_FORMAT);
default:
return "Произошла ошибка при форматировании даты или времени.";
}
}
public static LocalDateTime period(LocalDateTime dtStart, LocalDateTime dtEnd) {
// Возвращает разницу между двумя LocalDateTime
Period period = Period.between(dtStart.toLocalDate(), dtEnd.toLocalDate());