Jodatime を使用して、特定の月のすべての日を一覧表示する方法を探しています。具体的なコード サンプルがあるとよいでしょう。
1777 次
1 に答える
3
この質問に対する答えが見つからなかったため、ここにコードを投稿して、誰かが使用できるようにします。
// set your own print format here
private static final DateTimeFormatter DF=DateTimeFormat.forPattern("dd/MM/yyyy");
private List<String> createMonthLabels(LocalDate month) {
// add labels
List<String> daysInMonthLabels = new ArrayList<String>();
LocalDate firstDay = month.withDayOfMonth(1);
LocalDate nextMonthFirstDay = firstDay.plusMonths(1);
while (firstDay.isBefore(nextMonthFirstDay)) {
daysInMonthLabels.add(DF.print(firstDay));
firstDay = firstDay.plusDays(1);
}
return daysInMonthLabels;
}
于 2013-04-20T12:25:01.007 に答える