Skip to content

Commit

Permalink
feat: 시간 변환 유틸 클래스 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
dgjinsu committed Dec 9, 2023
1 parent 0869c7a commit e3223f4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main/java/jikgong/global/utils/TimeTransfer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package jikgong.global.utils;

import java.time.LocalDateTime;
import java.time.YearMonth;

public class TimeTransfer {
public static LocalDateTime getFirstDayOfMonth(LocalDateTime localDateTime) {
return localDateTime.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
}

public static LocalDateTime getLastDayOfMonth(LocalDateTime localDateTime) {
return localDateTime.withDayOfMonth(YearMonth.from(localDateTime).lengthOfMonth()).withHour(23).withMinute(59).withSecond(59).withNano(0);
}

public static LocalDateTime getFirstTimeOfDay(LocalDateTime localDateTime) {
return localDateTime.withHour(0).withMinute(0).withSecond(0).withNano(0);
}

public static LocalDateTime getLastTimeOfDay(LocalDateTime localDateTime) {
return localDateTime.withHour(23).withMinute(59).withSecond(59).withNano(0);
}
}

0 comments on commit e3223f4

Please sign in to comment.