本文整理汇总了Java中java.time.Month.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java Month.getValue方法的具体用法?Java Month.getValue怎么用?Java Month.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.Month
的用法示例。
在下文中一共展示了Month.getValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populateMonthPane
import java.time.Month; //导入方法依赖的package包/类
/**
* Creates and positions every node onto the GridPane for the given month and year.
* Uses 7 (weekdays) columns and (max.) 6 rows (weeks). The rows and columns are created on fly or
* are reused.
*
* @param monthPane The GradPane that is used for populating the DayNodes.
* @param month The month that should be displayed.
* @param year The year that should be displayed.
*/
private void populateMonthPane(GridPane monthPane, Month month, int year) {
monthPane.getChildren().clear();
int currentRow = 0;
for(LocalDate d = LocalDate.of(year, month, 1);
d.getMonthValue() == month.getValue();
d = d.plusDays(1)) {
Node dayNode = renderDayItem(d);
final LocalDate currentDate = d;
dayNode.setOnMouseClicked(event -> selectedDateProperty.set(currentDate));
int column = d.getDayOfWeek().getValue();
monthPane.add(dayNode, column, currentRow);
if(column == 7) {
currentRow++;
}
}
}
示例2: testDateTimeInfo
import java.time.Month; //导入方法依赖的package包/类
/**
* 获取时间节点的详细信息
*/
@Test
public void testDateTimeInfo(){
LocalDateTime ldt = LocalDateTime.now();
// 获取当前的年份
int year = ldt.getYear();
System.out.println(year);
// 当前年中的第几天
int dayOfYear = ldt.getDayOfYear();
System.out.println(dayOfYear);
// 当前月份中的第几天
int dayOfMonth = ldt.getDayOfMonth();
System.out.println(dayOfMonth);
// 当前周中的第几天
DayOfWeek dayOfWeek = ldt.getDayOfWeek();
int dayOfWeekValue = dayOfWeek.getValue();
System.out.println(dayOfWeekValue);
// 获取小时
int hour = ldt.getHour();
System.out.println(hour);
// 获取月份信息
Month month = ldt.getMonth();
int monthValue = month.getValue();
System.out.println(monthValue);
int ldtMonthValue = ldt.getMonthValue();
System.out.println(ldtMonthValue);
// 获取分钟
int minute = ldt.getMinute();
System.out.println(minute);
}