Foggy day
Android(JAVA) - How to get number of days in this month, YearMonth 본문
Android
Android(JAVA) - How to get number of days in this month, YearMonth
jinhan38 2021. 1. 7. 13:27It is the code about How to get number of days in this month as using YearMonth Class.
If you want to know number of days in this month, It is that.
public static int getDayCountOfThisMonth() {
Date date = new Date();
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
String time = sf.format(date);
YearMonth dayCount = YearMonth.from(LocalDate.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd")));
return dayCount.lengthOfMonth();
}
}
'Android' 카테고리의 다른 글
Android(Java) - vector asset about min sdk (0) | 2021.01.21 |
---|---|
Android(Java) - DatePickerDialog (0) | 2021.01.08 |
Android - Viewpager2 inside Viewpager2 (0) | 2021.01.01 |
Android(kotlin, java) - LayoutParams, Viewgroup to change margin, width, and height in code (0) | 2020.12.31 |
Android(Java, kotlin) - Appbar Animation with ViewPager inside Fragment (0) | 2020.12.29 |