本文整理汇总了Java中java.time.calendrical.DateTimeValueRange.of方法的典型用法代码示例。如果您正苦于以下问题:Java DateTimeValueRange.of方法的具体用法?Java DateTimeValueRange.of怎么用?Java DateTimeValueRange.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.calendrical.DateTimeValueRange
的用法示例。
在下文中一共展示了DateTimeValueRange.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: range
import java.time.calendrical.DateTimeValueRange; //导入方法依赖的package包/类
@Override
public DateTimeValueRange range(DateTimeField field) {
if (field instanceof ChronoField) {
ChronoField f = (ChronoField) field;
if (f.isDateField()) {
switch (f) {
case DAY_OF_MONTH:
return DateTimeValueRange.of(1, lengthOfMonth());
case DAY_OF_YEAR:
return DateTimeValueRange.of(1, lengthOfYear());
case ALIGNED_WEEK_OF_MONTH:
return DateTimeValueRange.of(1, getMonth() == Month.FEBRUARY && isLeapYear() == false ? 4 : 5);
case YEAR_OF_ERA:
return (getYear() <= 0 ? DateTimeValueRange.of(1, MAX_YEAR + 1) : DateTimeValueRange.of(1, MAX_YEAR));
}
return field.range();
}
throw new DateTimeException("Unsupported field: " + field.getName());
}
return field.doRange(this);
}
示例2: range
import java.time.calendrical.DateTimeValueRange; //导入方法依赖的package包/类
@Override
public DateTimeValueRange range(DateTimeField field) {
if (field instanceof ChronoField) {
if (isSupported(field)) {
ChronoField f = (ChronoField) field;
switch (f) {
case DAY_OF_MONTH:
return DateTimeValueRange.of(1, lengthOfMonth());
case DAY_OF_YEAR:
return DateTimeValueRange.of(1, lengthOfYear());
case ALIGNED_WEEK_OF_MONTH:
return DateTimeValueRange.of(1, 5); // TODO
case YEAR_OF_ERA:
return DateTimeValueRange.of(1, 1000); // TODO
}
return getChrono().range(f);
}
throw new DateTimeException("Unsupported field: " + field.getName());
}
return field.doRange(this);
}
示例3: range
import java.time.calendrical.DateTimeValueRange; //导入方法依赖的package包/类
@Override
public DateTimeValueRange range(DateTimeField field) {
if (field == YEAR_OF_ERA) {
return (getYear() <= 0 ? DateTimeValueRange.of(1, LocalDate.MAX_YEAR + 1) : DateTimeValueRange.of(1,
LocalDate.MAX_YEAR));
}
return super.range(field);
}
示例4: range
import java.time.calendrical.DateTimeValueRange; //导入方法依赖的package包/类
@Override
public DateTimeValueRange range(DateTimeField field) {
if (field == MONTH_OF_YEAR) {
return field.range();
} else if (field == DAY_OF_MONTH) {
return DateTimeValueRange.of(1, getMonth().minLength(), getMonth().maxLength());
}
return super.range(field);
}
示例5: range
import java.time.calendrical.DateTimeValueRange; //导入方法依赖的package包/类
@Override
public DateTimeValueRange range(DateTimeField field) {
if (field == YEAR_OF_ERA) {
return (this.year <= 0 ? DateTimeValueRange.of(1, MAX_YEAR + 1) : DateTimeValueRange.of(1, MAX_YEAR));
}
return super.range(field);
}
示例6: test_equals1
import java.time.calendrical.DateTimeValueRange; //导入方法依赖的package包/类
public void test_equals1() {
DateTimeValueRange a = DateTimeValueRange.of(1, 2, 3, 4);
DateTimeValueRange b = DateTimeValueRange.of(1, 2, 3, 4);
assertEquals(a.equals(a), true);
assertEquals(a.equals(b), true);
assertEquals(b.equals(a), true);
assertEquals(b.equals(b), true);
assertEquals(a.hashCode() == b.hashCode(), true);
}
示例7: test_equals2
import java.time.calendrical.DateTimeValueRange; //导入方法依赖的package包/类
public void test_equals2() {
DateTimeValueRange a = DateTimeValueRange.of(1, 2, 3, 4);
assertEquals(a.equals(DateTimeValueRange.of(0, 2, 3, 4)), false);
assertEquals(a.equals(DateTimeValueRange.of(1, 3, 3, 4)), false);
assertEquals(a.equals(DateTimeValueRange.of(1, 2, 4, 4)), false);
assertEquals(a.equals(DateTimeValueRange.of(1, 2, 3, 5)), false);
}
示例8: actualRange
import java.time.calendrical.DateTimeValueRange; //导入方法依赖的package包/类
private DateTimeValueRange actualRange(int calendarField) {
Calendar jcal = Calendar.getInstance(JapaneseChrono.LOCALE);
jcal.set(Calendar.ERA, this.era.getValue() + JapaneseEra.ERA_OFFSET);
jcal.set(this.yearOfEra, this.isoDate.getMonthValue() - 1, this.isoDate.getDayOfMonth());
return DateTimeValueRange.of(jcal.getActualMinimum(calendarField), jcal.getActualMaximum(calendarField));
}
示例9: test_serialization
import java.time.calendrical.DateTimeValueRange; //导入方法依赖的package包/类
public void test_serialization() throws Exception {
Object obj = DateTimeValueRange.of(1, 2, 3, 4);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(obj);
oos.close();
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
assertEquals(ois.readObject(), obj);
}
示例10: test_of_longlong
import java.time.calendrical.DateTimeValueRange; //导入方法依赖的package包/类
public void test_of_longlong() {
DateTimeValueRange test = DateTimeValueRange.of(1, 12);
assertEquals(test.getMinimum(), 1);
assertEquals(test.getLargestMinimum(), 1);
assertEquals(test.getSmallestMaximum(), 12);
assertEquals(test.getMaximum(), 12);
assertEquals(test.isFixed(), true);
assertEquals(test.isIntValue(), true);
}
示例11: test_of_longlong_big
import java.time.calendrical.DateTimeValueRange; //导入方法依赖的package包/类
public void test_of_longlong_big() {
DateTimeValueRange test = DateTimeValueRange.of(1, 123456789012345L);
assertEquals(test.getMinimum(), 1);
assertEquals(test.getLargestMinimum(), 1);
assertEquals(test.getSmallestMaximum(), 123456789012345L);
assertEquals(test.getMaximum(), 123456789012345L);
assertEquals(test.isFixed(), true);
assertEquals(test.isIntValue(), false);
}
示例12: test_of_longlonglonglong
import java.time.calendrical.DateTimeValueRange; //导入方法依赖的package包/类
public void test_of_longlonglonglong() {
DateTimeValueRange test = DateTimeValueRange.of(1, 2, 28, 31);
assertEquals(test.getMinimum(), 1);
assertEquals(test.getLargestMinimum(), 2);
assertEquals(test.getSmallestMaximum(), 28);
assertEquals(test.getMaximum(), 31);
assertEquals(test.isFixed(), false);
assertEquals(test.isIntValue(), true);
}
示例13: test_isValidValue_long_int
import java.time.calendrical.DateTimeValueRange; //导入方法依赖的package包/类
public void test_isValidValue_long_int() {
DateTimeValueRange test = DateTimeValueRange.of(1, 28, 31);
assertEquals(test.isValidValue(0), false);
assertEquals(test.isValidValue(1), true);
assertEquals(test.isValidValue(31), true);
assertEquals(test.isValidValue(32), false);
}
示例14: range
import java.time.calendrical.DateTimeValueRange; //导入方法依赖的package包/类
@Override
public DateTimeValueRange range(ChronoField field) {
switch (field) {
case DAY_OF_MONTH:
case DAY_OF_WEEK:
case MICRO_OF_DAY:
case MICRO_OF_SECOND:
case HOUR_OF_DAY:
case HOUR_OF_AMPM:
case MINUTE_OF_DAY:
case MINUTE_OF_HOUR:
case SECOND_OF_DAY:
case SECOND_OF_MINUTE:
case MILLI_OF_DAY:
case MILLI_OF_SECOND:
case NANO_OF_DAY:
case NANO_OF_SECOND:
case CLOCK_HOUR_OF_DAY:
case CLOCK_HOUR_OF_AMPM:
case EPOCH_DAY:
case EPOCH_MONTH:
return field.range();
}
Calendar jcal = Calendar.getInstance(LOCALE);
int fieldIndex;
switch (field) {
case ERA:
return DateTimeValueRange.of(jcal.getMinimum(Calendar.ERA) - JapaneseEra.ERA_OFFSET,
jcal.getMaximum(Calendar.ERA) - JapaneseEra.ERA_OFFSET);
case YEAR:
case YEAR_OF_ERA:
return DateTimeValueRange.of(LocalDate.MIN_YEAR, jcal.getGreatestMinimum(Calendar.YEAR),
jcal.getLeastMaximum(Calendar.YEAR), LocalDate.MAX_YEAR);
case MONTH_OF_YEAR:
return DateTimeValueRange.of(jcal.getMinimum(Calendar.MONTH) + 1, jcal.getGreatestMinimum(Calendar.MONTH) + 1,
jcal.getLeastMaximum(Calendar.MONTH) + 1, jcal.getMaximum(Calendar.MONTH) + 1);
case DAY_OF_YEAR:
fieldIndex = Calendar.DAY_OF_YEAR;
break;
default :
// TODO: review the remaining fields
throw new UnsupportedOperationException("Unimplementable field: " + field);
}
return DateTimeValueRange.of(jcal.getMinimum(fieldIndex), jcal.getGreatestMinimum(fieldIndex),
jcal.getLeastMaximum(fieldIndex), jcal.getMaximum(fieldIndex));
}
示例15: test_equals_null
import java.time.calendrical.DateTimeValueRange; //导入方法依赖的package包/类
public void test_equals_null() {
DateTimeValueRange a = DateTimeValueRange.of(1, 12);
assertEquals(a.equals(null), false);
}