本文整理匯總了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);
}