Last active
August 29, 2015 13:58
-
-
Save tarchan/10237894 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 月オブジェクトを取得 | |
YearMonth currentMonth = YearMonth.now(); | |
YearMonth backMonth = currentMonth.minusMonths(1); | |
YearMonth nextMonth = currentMonth.plusMonths(1); | |
// 日オブジェクトを取得 | |
LocalDate firstDay = currentMonth.atDay(1); | |
LocalDate endDay = currentMonth.atEndOfMonth(); | |
LocalDate endDay2 = currentMonth.atDay(currentMonth.lengthOfMonth()); | |
// 曜日オブジェクトを取得 | |
DayOfWeek week = firstDay.getDayOfWeek(); | |
// 曜日を日本語で表示 | |
week.getDisplayName(TextStyle.SHORT, Locale.JAPANESE) | |
// 月を指定した書式で表示(2014/04) | |
currentMonth.format(DateTimeFormatter.ofPattern("yyyy/MM"); | |
// 月を英語で表示(April) | |
currentMonth.format(DateTimeFormatter.ofPattern("MMMM", Locale.ENGLISH); | |
// 年を日本語で表示(平成26年) | |
JapaneseDate jp = JapaneseDate.from(currentMonth.atEndOfMonth()); | |
jp.format(DateTimeFormatter.ofPattern("Gy年", Locale.JAPANESE); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment