Today I Learned/2022

LocalDate, LocalDateTime ์›”์˜ 1์ผ, ๋ง์ผ ๊ตฌํ•˜๊ธฐ ๋ฐ Min/Max ์‹œ๊ฐ„ ๊ตฌํ•˜๊ธฐ

YURI๐Ÿ•๐Ÿ“๐Ÿถ 2022. 10. 24. 12:07
๋ฐ˜์‘ํ˜•

๋‹น์›” 1์ผ ๋ฐ ๋ง์ผ ๊ตฌํ•˜๊ธฐ

  1. 1์ผ : firstDayOfMonth()
  2. ๋ง์ผ : lastDayOfMonth()
  3. 00:00:00 ๋ฐ 23:59:59๋Š” LocalTime.MIN ๋ฐ LocalTime.MAX ๋ฅผ ์ด์šฉํ•œ๋‹ค
import static java.time.temporal.TemporalAdjusters.*

LocalDateTime today = LocalDateTime.now();
LocalDateTime starttime = today.with(firstDayOfMonth()).with(LocalTime.MIN); // ๋‹น์›” 1์ผ 00:00:00
LocalDateTime endtime = today.with(lastDayOfMonth()).with(LocalTime.MAX); // ๋‹น์›” ๋งˆ์ง€๋ง‰๋‚  23:59:59

 

Field Summary

FieldsModifier and TypeField and Description

static LocalTime MAX
The maximum supported LocalTime, '23:59:59.999999999'.
static LocalTime MIDNIGHT
The time of midnight at the start of the day, '00:00'.
static LocalTime MIN
The minimum supported LocalTime, '00:00'.
static LocalTime NOON
The time of noon in the middle of the day, '12:00'.

 

๐Ÿ‘ Reference

๋ฐ˜์‘ํ˜•