下面列出了java.time.chrono.HijrahDate#with ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Test
public void test_withDayOfYear() {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1434, 1);
for (int i = 1; i <= hd.lengthOfYear(); i++) {
HijrahDate hd2 = hd.with(DAY_OF_YEAR, i);
int doy = hd2.get(DAY_OF_YEAR);
assertEquals(doy, i, "with(DAY_OF_YEAR) incorrect for " + i + " " + hd2);
}
}
@Test
public void test_withDayOfYear() {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1434, 1);
for (int i = 1; i <= hd.lengthOfYear(); i++) {
HijrahDate hd2 = hd.with(DAY_OF_YEAR, i);
int doy = hd2.get(DAY_OF_YEAR);
assertEquals(doy, i, "with(DAY_OF_YEAR) incorrect for " + i + " " + hd2);
}
}
@Test
public void test_withDayOfYear() {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1434, 1);
for (int i = 1; i <= hd.lengthOfYear(); i++) {
HijrahDate hd2 = hd.with(DAY_OF_YEAR, i);
int doy = hd2.get(DAY_OF_YEAR);
assertEquals(doy, i, "with(DAY_OF_YEAR) incorrect for " + i + " " + hd2);
}
}
@Test
public void test_withDayOfYear() {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1434, 1);
for (int i = 1; i <= hd.lengthOfYear(); i++) {
HijrahDate hd2 = hd.with(DAY_OF_YEAR, i);
int doy = hd2.get(DAY_OF_YEAR);
assertEquals(doy, i, "with(DAY_OF_YEAR) incorrect for " + i + " " + hd2);
}
}
@Test
public void test_withDayOfYear() {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1434, 1);
for (int i = 1; i <= hd.lengthOfYear(); i++) {
HijrahDate hd2 = hd.with(DAY_OF_YEAR, i);
int doy = hd2.get(DAY_OF_YEAR);
assertEquals(doy, i, "with(DAY_OF_YEAR) incorrect for " + i + " " + hd2);
}
}
@Test(expectedExceptions=java.time.DateTimeException.class)
public void test_withDayOfYearTooSmall() {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1);
HijrahDate hd2 = hd.with(DAY_OF_YEAR, 0);
}
@Test(expectedExceptions=java.time.DateTimeException.class)
public void test_withDayOfYearTooSmall() {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1);
HijrahDate hd2 = hd.with(DAY_OF_YEAR, 0);
}
@Test(dataProvider="monthDays")
public void test_lastDayOfMonth(int year, int month, int numDays) {
HijrahDate hDate = HijrahChronology.INSTANCE.date(year, month, 1);
hDate = hDate.with(TemporalAdjusters.lastDayOfMonth());
assertEquals(hDate.get(ChronoField.DAY_OF_MONTH), numDays);
}
@Test(dataProvider="monthDays")
public void test_lastDayOfMonth(int year, int month, int numDays) {
HijrahDate hDate = HijrahChronology.INSTANCE.date(year, month, 1);
hDate = hDate.with(TemporalAdjusters.lastDayOfMonth());
assertEquals(hDate.get(ChronoField.DAY_OF_MONTH), numDays);
}
@Test(expectedExceptions=java.time.DateTimeException.class)
public void test_withDayOfYearTooSmall() {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1);
HijrahDate hd2 = hd.with(DAY_OF_YEAR, 0);
}
@Test(expectedExceptions=java.time.DateTimeException.class)
public void test_withDayOfYearTooSmall() {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1);
HijrahDate hd2 = hd.with(DAY_OF_YEAR, 0);
}
@Test(expectedExceptions=java.time.DateTimeException.class)
public void test_withDayOfYearTooLarge() {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1);
HijrahDate hd2 = hd.with(DAY_OF_YEAR, hd.lengthOfYear() + 1);
}
@Test(expectedExceptions=java.time.DateTimeException.class)
public void test_withDayOfYearTooSmall() {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1);
HijrahDate hd2 = hd.with(DAY_OF_YEAR, 0);
}
@Test(expectedExceptions=java.time.DateTimeException.class)
public void test_withDayOfYearTooSmall() {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1);
HijrahDate hd2 = hd.with(DAY_OF_YEAR, 0);
}
@Test(dataProvider="monthDays")
public void test_lastDayOfMonth(int year, int month, int numDays) {
HijrahDate hDate = HijrahChronology.INSTANCE.date(year, month, 1);
hDate = hDate.with(TemporalAdjusters.lastDayOfMonth());
assertEquals(hDate.get(ChronoField.DAY_OF_MONTH), numDays);
}
@Test(dataProvider="monthDays")
public void test_lastDayOfMonth(int year, int month, int numDays) {
HijrahDate hDate = HijrahChronology.INSTANCE.date(year, month, 1);
hDate = hDate.with(TemporalAdjusters.lastDayOfMonth());
assertEquals(hDate.get(ChronoField.DAY_OF_MONTH), numDays);
}
@Test(expectedExceptions=java.time.DateTimeException.class)
public void test_withDayOfYearTooSmall() {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1);
HijrahDate hd2 = hd.with(DAY_OF_YEAR, 0);
}
@Test(expectedExceptions=java.time.DateTimeException.class)
public void test_withDayOfYearTooLarge() {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1);
HijrahDate hd2 = hd.with(DAY_OF_YEAR, hd.lengthOfYear() + 1);
}
@Test(expectedExceptions=java.time.DateTimeException.class)
public void test_withDayOfYearTooLarge() {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1);
HijrahDate hd2 = hd.with(DAY_OF_YEAR, hd.lengthOfYear() + 1);
}
@Test(expectedExceptions=java.time.DateTimeException.class)
public void test_withDayOfYearTooSmall() {
HijrahDate hd = HijrahChronology.INSTANCE.dateYearDay(1435, 1);
HijrahDate hd2 = hd.with(DAY_OF_YEAR, 0);
}