java核心技術卷I-日期函數

日期函數

java.time.LocalDate 8

static LocalTime now( )

構造一個表示當前日期的對象。

static LocalTime of(int year, int month , int day )

構造一個表示給定日期的對象。

int getYear( )
int getMonthValue( )
int getDayOfMonth( )

得到當前日期的年、 月和曰。

DayOfWeek getDayOfWeek

得到當前日期是星期幾, 作爲 DayOfWeek 類的一個實例返回。 調用 getValue 來得到1 ~ 7 之間的一個數, 表示這是星期幾, 1 表示星期一, 7 表示星期日。

Local Date piusDays(int n )
Local Date minusDays(int n)

生成當前日期之後或之前 n 天的日期。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章