本文整理匯總了Java中java.time.YearMonth.of方法的典型用法代碼示例。如果您正苦於以下問題:Java YearMonth.of方法的具體用法?Java YearMonth.of怎麽用?Java YearMonth.of使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.time.YearMonth
的用法示例。
在下文中一共展示了YearMonth.of方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: data_atEndOfMonth
import java.time.YearMonth; //導入方法依賴的package包/類
@DataProvider(name="atEndOfMonth")
Object[][] data_atEndOfMonth() {
return new Object[][] {
{YearMonth.of(2008, 1), LocalDate.of(2008, 1, 31)},
{YearMonth.of(2008, 2), LocalDate.of(2008, 2, 29)},
{YearMonth.of(2008, 3), LocalDate.of(2008, 3, 31)},
{YearMonth.of(2008, 4), LocalDate.of(2008, 4, 30)},
{YearMonth.of(2008, 5), LocalDate.of(2008, 5, 31)},
{YearMonth.of(2008, 6), LocalDate.of(2008, 6, 30)},
{YearMonth.of(2008, 12), LocalDate.of(2008, 12, 31)},
{YearMonth.of(2009, 1), LocalDate.of(2009, 1, 31)},
{YearMonth.of(2009, 2), LocalDate.of(2009, 2, 28)},
{YearMonth.of(2009, 3), LocalDate.of(2009, 3, 31)},
{YearMonth.of(2009, 4), LocalDate.of(2009, 4, 30)},
{YearMonth.of(2009, 5), LocalDate.of(2009, 5, 31)},
{YearMonth.of(2009, 6), LocalDate.of(2009, 6, 30)},
{YearMonth.of(2009, 12), LocalDate.of(2009, 12, 31)},
};
}
示例2: data_plus_long_TemporalUnit
import java.time.YearMonth; //導入方法依賴的package包/類
@DataProvider(name="plus_long_TemporalUnit")
Object[][] data_plus_long_TemporalUnit() {
return new Object[][] {
{YearMonth.of(1, 10), 1, ChronoUnit.YEARS, YearMonth.of(2, 10), null},
{YearMonth.of(1, 10), -12, ChronoUnit.YEARS, YearMonth.of(-11, 10), null},
{YearMonth.of(1, 10), 0, ChronoUnit.YEARS, YearMonth.of(1, 10), null},
{YearMonth.of(999999999, 12), 0, ChronoUnit.YEARS, YearMonth.of(999999999, 12), null},
{YearMonth.of(-999999999, 1), 0, ChronoUnit.YEARS, YearMonth.of(-999999999, 1), null},
{YearMonth.of(0, 1), -999999999, ChronoUnit.YEARS, YearMonth.of(-999999999, 1), null},
{YearMonth.of(0, 12), 999999999, ChronoUnit.YEARS, YearMonth.of(999999999, 12), null},
{YearMonth.of(1, 10), 1, ChronoUnit.MONTHS, YearMonth.of(1, 11), null},
{YearMonth.of(1, 10), -12, ChronoUnit.MONTHS, YearMonth.of(0, 10), null},
{YearMonth.of(1, 10), 0, ChronoUnit.MONTHS, YearMonth.of(1, 10), null},
{YearMonth.of(999999999, 12), 0, ChronoUnit.MONTHS, YearMonth.of(999999999, 12), null},
{YearMonth.of(-999999999, 1), 0, ChronoUnit.MONTHS, YearMonth.of(-999999999, 1), null},
{YearMonth.of(-999999999, 2), -1, ChronoUnit.MONTHS, YearMonth.of(-999999999, 1), null},
{YearMonth.of(999999999, 3), 9, ChronoUnit.MONTHS, YearMonth.of(999999999, 12), null},
{YearMonth.of(-1, 10), 1, ChronoUnit.ERAS, YearMonth.of(2, 10), null},
{YearMonth.of(5, 10), 1, ChronoUnit.CENTURIES, YearMonth.of(105, 10), null},
{YearMonth.of(5, 10), 1, ChronoUnit.DECADES, YearMonth.of(15, 10), null},
{YearMonth.of(999999999, 12), 1, ChronoUnit.MONTHS, null, DateTimeException.class},
{YearMonth.of(-999999999, 1), -1, ChronoUnit.MONTHS, null, DateTimeException.class},
{YearMonth.of(1, 1), 0, ChronoUnit.DAYS, null, DateTimeException.class},
{YearMonth.of(1, 1), 0, ChronoUnit.WEEKS, null, DateTimeException.class},
};
}
示例3: updateMonths
import java.time.YearMonth; //導入方法依賴的package包/類
private void updateMonths() {
YearView yearPage = getSkinnable();
LocalDate date = yearPage.getDate();
int year = date.getYear();
for (Month month : Month.values()) {
YearMonth yearMonth = YearMonth.of(year, month);
YearMonthView view = yearPage.getMonthView(month);
view.setMinSize(0, 0);
view.setDate(yearMonth.atDay(1));
}
}
示例4: shouldSuccessfullyCreateRequestWithYearMonthDate
import java.time.YearMonth; //導入方法依賴的package包/類
@Test
public void shouldSuccessfullyCreateRequestWithYearMonthDate() {
final YearMonth yearMonth = YearMonth.of(2017, 5);
final RestRequest<List<HistoricalDailyStats>> request = new HistoricalDailyStatsRequestBuilder()
.withDate(yearMonth)
.build();
assertThat(request.getMethodType()).isEqualTo(MethodType.GET);
assertThat(request.getPath()).isEqualTo("/stats/historical/daily");
assertThat(request.getResponseType()).isEqualTo(new GenericType<List<HistoricalDailyStats>>() {});
assertThat(request.getPathParams()).isEmpty();
assertThat(request.getQueryParams()).contains(entry("date", "201705"));
}
示例5: test_isValidDay_int_febLeap
import java.time.YearMonth; //導入方法依賴的package包/類
@Test
public void test_isValidDay_int_febLeap() {
YearMonth test = YearMonth.of(2008, 2);
assertEquals(test.isValidDay(1), true);
assertEquals(test.isValidDay(29), true);
assertEquals(test.isValidDay(-1), false);
assertEquals(test.isValidDay(0), false);
assertEquals(test.isValidDay(30), false);
assertEquals(test.isValidDay(32), false);
}
示例6: test_isValidDay_int_febNonLeap
import java.time.YearMonth; //導入方法依賴的package包/類
@Test
public void test_isValidDay_int_febNonLeap() {
YearMonth test = YearMonth.of(2007, 2);
assertEquals(test.isValidDay(1), true);
assertEquals(test.isValidDay(28), true);
assertEquals(test.isValidDay(-1), false);
assertEquals(test.isValidDay(0), false);
assertEquals(test.isValidDay(29), false);
assertEquals(test.isValidDay(32), false);
}
示例7: factory_ints
import java.time.YearMonth; //導入方法依賴的package包/類
@Test
public void factory_ints() {
YearMonth test = YearMonth.of(2008, 2);
check(test, 2008, 2);
}
示例8: test_plusYears_long_invalidTooSmall
import java.time.YearMonth; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeException.class)
public void test_plusYears_long_invalidTooSmall() {
YearMonth test = YearMonth.of(Year.MIN_VALUE, 6);
test.plusYears(-1);
}
示例9: test_adjustDate_equal
import java.time.YearMonth; //導入方法依賴的package包/類
@Test
public void test_adjustDate_equal() {
YearMonth test = YearMonth.of(2008, 6);
LocalDate date = LocalDate.of(2008, 6, 30);
assertEquals(test.adjustInto(date), date);
}
示例10: test_minusMonths_long_invalidTooLargeMaxSubtractMin
import java.time.YearMonth; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeException.class)
public void test_minusMonths_long_invalidTooLargeMaxSubtractMin() {
YearMonth test = YearMonth.of(Year.MAX_VALUE, 12);
test.minusMonths(Long.MIN_VALUE);
}
示例11: test_toString
import java.time.YearMonth; //導入方法依賴的package包/類
@Test(dataProvider="sampleToString")
public void test_toString(int y, int m, String expected) {
YearMonth test = YearMonth.of(y, m);
String str = test.toString();
assertEquals(str, expected);
}
示例12: test_adjustDate_preserveDoM
import java.time.YearMonth; //導入方法依賴的package包/類
@Test
public void test_adjustDate_preserveDoM() {
YearMonth test = YearMonth.of(2011, 3);
LocalDate date = LocalDate.of(2008, 2, 29);
assertEquals(test.adjustInto(date), LocalDate.of(2011, 3, 29));
}
示例13: test_minusMonths_long_invalidTooSmall
import java.time.YearMonth; //導入方法依賴的package包/類
@Test(expectedExceptions={DateTimeException.class})
public void test_minusMonths_long_invalidTooSmall() {
YearMonth test = YearMonth.of(Year.MIN_VALUE, 1);
test.minusMonths(1);
}
示例14: test_plusYears_long_invalidTooLargeMaxAddMin
import java.time.YearMonth; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeException.class)
public void test_plusYears_long_invalidTooLargeMaxAddMin() {
YearMonth test = YearMonth.of(Year.MAX_VALUE, 12);
test.plusYears(Long.MIN_VALUE);
}
示例15: test_lengthOfMonth_febNonLeap
import java.time.YearMonth; //導入方法依賴的package包/類
@Test
public void test_lengthOfMonth_febNonLeap() {
YearMonth test = YearMonth.of(2007, 2);
assertEquals(test.lengthOfMonth(), 28);
}