Java 类org.joda.time.Partial 实例源码

项目:cql_engine    文件:Value.java   
public static Object minValue(Type type) {
    if (type == Integer.class) {
        return Integer.MIN_VALUE;
    }
    else if (type == BigDecimal.class) {
        return new BigDecimal("-9999999999999999999999999999.99999999");
    }
    else if (type == Quantity.class) {
        return new Quantity().withValue((BigDecimal)minValue(BigDecimal.class));
    }
    else if (type == DateTime.class) {
        return new DateTime(new Partial(DateTime.fields, new int[] {0001, 1, 1, 0, 0, 0, 0}));
    }
    else if (type == Time.class) {
        return new Time(new Partial(Time.fields, new int[] {0, 0, 0, 0}));
    }

    throw new NotImplementedException(String.format("MinValue is not implemented for type %s.", type.getTypeName()));
}
项目:cql_engine    文件:Value.java   
public static Object maxValue(Type type) {
    if (type == Integer.class) {
        return Integer.MAX_VALUE;
    }
    else if (type == BigDecimal.class) {
        return new BigDecimal("9999999999999999999999999999.99999999");
    }
    else if (type == Quantity.class) {
        return new Quantity().withValue((BigDecimal)maxValue(BigDecimal.class));
    }
    else if (type == DateTime.class) {
        return new DateTime(new Partial(DateTime.fields, new int[] {9999, 12, 31, 23, 59, 59, 999}));
    }
    else if (type == Time.class) {
        return new Time(new Partial(Time.fields, new int[] {23, 59, 59, 999}));
    }

    throw new NotImplementedException(String.format("MaxValue is not implemented for type %s.", type.getTypeName()));
}
项目:cql_engine    文件:TimeEvaluator.java   
@Override
public Object evaluate(Context context) {

    if (this.getHour() == null) {
        return null;
    }

    Integer hour = (Integer)this.getHour().evaluate(context);
    Integer minute = (this.getMinute() == null) ? null : (Integer)this.getMinute().evaluate(context);
    Integer second = (this.getSecond() == null) ? null : (Integer)this.getSecond().evaluate(context);
    Integer millis = (this.getMillisecond() == null) ? null : (Integer)this.getMillisecond().evaluate(context);

    DateTimeZone timeZone =
            BaseTemporal.resolveDateTimeZone(
                    this.getTimezoneOffset() != null
                            ? (BigDecimal) this.getTimezoneOffset().evaluate(context)
                            : null);

    if (BaseTemporal.formatCheck(new ArrayList<>(Arrays.asList(hour, minute, second, millis)))) {
        int [] values = DateTime.getValues(hour, minute, second, millis);
        return new Time(new Partial(Time.getFields(values.length), values), timeZone);
    }

    throw new IllegalArgumentException("Time format is invalid");
}
项目:cql_engine    文件:ToTimeEvaluator.java   
public static Object toTime(Object operand) {
    if (operand == null) {
        return null;
    }

    String[] timeAndTimezone = operand.toString().replace('T', ' ').replace('Z', ' ').trim().split("[\\+-]");
    String[] time = timeAndTimezone[0].split("\\W");
    int[] values = new int[time.length];
    for (int i = 0; i < values.length; ++i) {
        values[i] = Integer.parseInt(time[i]);
    }

    return new Time(
            new Partial(Time.getFields(values.length), values),
            BaseTemporal.resolveDateTimeZone(getTimezone(operand.toString()))
    );
}
项目:cql_engine    文件:CqlArithmeticFunctionsTest.java   
/**
 * {@link org.opencds.cqf.cql.elm.execution.Max#evaluate(Context)}
 */
@Test
public void testMaximum() throws JAXBException {
    Context context = new Context(library);
    Object result = context.resolveExpressionRef("IntegerMaxValue").getExpression().evaluate(context);
    assertThat(result, is(Integer.MAX_VALUE));

    result = context.resolveExpressionRef("DecimalMaxValue").getExpression().evaluate(context);
    Assert.assertTrue(((BigDecimal) result).compareTo((BigDecimal) Value.maxValue(BigDecimal.class)) == 0);

    // TODO: QuantityMaxValue

    result = context.resolveExpressionRef("DateTimeMaxValue").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(7), new int[] {9999, 12, 31, 23, 59, 59, 999})));

    result = context.resolveExpressionRef("TimeMaxValue").getExpression().evaluate(context);
    assertThat(((Time)result).getPartial(), is(new Partial(Time.getFields(4), new int[] {23, 59, 59, 999})));
}
项目:cql_engine    文件:CqlArithmeticFunctionsTest.java   
/**
 * {@link org.opencds.cqf.cql.elm.execution.Min#evaluate(Context)}
 */
@Test
public void testMinimum() throws JAXBException {
    Context context = new Context(library);
    Object result = context.resolveExpressionRef("IntegerMinValue").getExpression().evaluate(context);
    assertThat(result, is(Integer.MIN_VALUE));

    result = context.resolveExpressionRef("DecimalMinValue").getExpression().evaluate(context);
    Assert.assertTrue(((BigDecimal) result).compareTo((BigDecimal) Value.minValue(BigDecimal.class)) == 0);

    // TODO: QuantityMinValue

    result = context.resolveExpressionRef("DateTimeMinValue").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(7), new int[] {0001, 1, 1, 0, 0, 0, 0})));

    result = context.resolveExpressionRef("TimeMinValue").getExpression().evaluate(context);
    assertThat(((Time)result).getPartial(), is(new Partial(Time.getFields(4), new int[] {0, 0, 0, 0})));
}
项目:cql_engine    文件:CqlListOperatorsTest.java   
/**
 * {@link org.opencds.cqf.cql.elm.execution.ExceptEvaluator#evaluate(Context)}
 */
@Test
public void testExcept() throws JAXBException {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("ExceptEmptyListAndEmptyList").getExpression().evaluate(context);
    assertThat(result, is(Collections.emptyList()));

    result = context.resolveExpressionRef("Except1234And23").getExpression().evaluate(context);
    assertThat(result, is(Arrays.asList(1, 4)));

    result = context.resolveExpressionRef("Except23And1234").getExpression().evaluate(context);
    assertThat(result, is(Collections.emptyList()));

    result = context.resolveExpressionRef("ExceptDateTime").getExpression().evaluate(context);
    assertThat(((DateTime)((List)result).get(0)).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2012, 5, 10})));
    assertThat(((List)result).size(), is(1));

    result = context.resolveExpressionRef("ExceptTime").getExpression().evaluate(context);
    assertThat(((Time)((List)result).get(0)).getPartial(), is(new Partial(Time.getFields(4), new int[] {15, 59, 59, 999})));
    assertThat(((List)result).size(), is(1));

    result = context.resolveExpressionRef("ExceptNullRight").getExpression().evaluate(context);
    assertThat(result, is(Arrays.asList(1, 4)));
}
项目:cql_engine    文件:CqlListOperatorsTest.java   
/**
 * {@link org.opencds.cqf.cql.elm.execution.FlattenEvaluator#evaluate(Context)}
 */
@Test
public void testFlatten() throws JAXBException {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("FlattenEmpty").getExpression().evaluate(context);
    assertThat(result, is(Collections.emptyList()));

    result = context.resolveExpressionRef("FlattenListNullAndNull").getExpression().evaluate(context);
    assertThat(result, is(Arrays.asList(null, null)));

    result = context.resolveExpressionRef("FlattenList12And34").getExpression().evaluate(context);
    assertThat(result, is(Arrays.asList(1, 2, 3, 4)));

    result = context.resolveExpressionRef("FlattenDateTime").getExpression().evaluate(context);
    assertThat(((DateTime)((List)result).get(0)).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2012, 5, 10})));
    assertThat(((DateTime)((List)result).get(1)).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2014, 12, 10})));
    assertThat(((List)result).size(), is(2));

    result = context.resolveExpressionRef("FlattenTime").getExpression().evaluate(context);
    assertThat(((Time)((List)result).get(0)).getPartial(), is(new Partial(Time.getFields(4), new int[] {15, 59, 59, 999})));
    assertThat(((Time)((List)result).get(1)).getPartial(), is(new Partial(Time.getFields(4), new int[] {20, 59, 59, 999})));
    assertThat(((List)result).size(), is(2));
}
项目:cql_engine    文件:CqlListOperatorsTest.java   
/**
 * {@link org.opencds.cqf.cql.elm.execution.FirstEvaluator#evaluate(Context)}
 */
@Test
public void testFirst() throws JAXBException {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("FirstEmpty").getExpression().evaluate(context);
    assertThat(result, is(nullValue()));

    result = context.resolveExpressionRef("FirstNull1").getExpression().evaluate(context);
    assertThat(result, is(nullValue()));

    result = context.resolveExpressionRef("First1Null").getExpression().evaluate(context);
    assertThat(result, is(1));

    result = context.resolveExpressionRef("First12").getExpression().evaluate(context);
    assertThat(result, is(1));

    result = context.resolveExpressionRef("FirstDateTime").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2012, 5, 10})));

    result = context.resolveExpressionRef("FirstTime").getExpression().evaluate(context);
    assertThat(((Time)result).getPartial(), is(new Partial(Time.getFields(4), new int[] {15, 59, 59, 999})));
}
项目:cql_engine    文件:CqlListOperatorsTest.java   
/**
 * {@link org.opencds.cqf.cql.elm.execution.IndexerEvaluator#evaluate(Context)}
 */
@Test
public void testIndexer() throws JAXBException {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("IndexerNull1").getExpression().evaluate(context);
    assertThat(result, is(nullValue()));

    result = context.resolveExpressionRef("Indexer0Of12").getExpression().evaluate(context);
    assertThat(result, is(1));

    result = context.resolveExpressionRef("Indexer1Of12").getExpression().evaluate(context);
    assertThat(result, is(2));

    result = context.resolveExpressionRef("Indexer2Of12").getExpression().evaluate(context);
    assertThat(result, is(nullValue()));

    result = context.resolveExpressionRef("IndexerNeg1Of12").getExpression().evaluate(context);
    assertThat(result, is(nullValue()));

    result = context.resolveExpressionRef("IndexerDateTime").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2012, 5, 10})));

    result = context.resolveExpressionRef("IndexerTime").getExpression().evaluate(context);
    assertThat(((Time)result).getPartial(), is(new Partial(Time.getFields(4), new int[] {15, 59, 59, 999})));
}
项目:cql_engine    文件:CqlListOperatorsTest.java   
/**
 * {@link org.opencds.cqf.cql.elm.execution.IntersectEvaluator#evaluate(Context)}
 */
@Test
public void testIntersect() throws JAXBException {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("IntersectEmptyListAndEmptyList").getExpression().evaluate(context);
    assertThat(result, is(Collections.emptyList()));

    result = context.resolveExpressionRef("Intersect1234And23").getExpression().evaluate(context);
    assertThat(result, is(Arrays.asList(2, 3)));

    result = context.resolveExpressionRef("Intersect23And1234").getExpression().evaluate(context);
    assertThat(result, is(Arrays.asList(2, 3)));

    result = context.resolveExpressionRef("IntersectDateTime").getExpression().evaluate(context);
    assertThat(((DateTime)((ArrayList)result).get(0)).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2012, 5, 10})));
    assertThat(((DateTime)((ArrayList)result).get(1)).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2014, 12, 10})));
    assertThat(((ArrayList)result).size(), is(2));

    result = context.resolveExpressionRef("IntersectTime").getExpression().evaluate(context);
    assertThat(((Time)((ArrayList)result).get(0)).getPartial(), is(new Partial(Time.getFields(4), new int[] {15, 59, 59, 999})));
    assertThat(((Time)((ArrayList)result).get(1)).getPartial(), is(new Partial(Time.getFields(4), new int[] {20, 59, 59, 999})));
    assertThat(((ArrayList)result).size(), is(2));
}
项目:cql_engine    文件:CqlListOperatorsTest.java   
/**
 * {@link org.opencds.cqf.cql.elm.execution.LastEvaluator#evaluate(Context)}
 */
@Test
public void testLast() throws JAXBException {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("LastEmpty").getExpression().evaluate(context);
    assertThat(result, is(nullValue()));

    result = context.resolveExpressionRef("LastNull1").getExpression().evaluate(context);
    assertThat(result, is(1));

    result = context.resolveExpressionRef("Last1Null").getExpression().evaluate(context);
    assertThat(result, is(nullValue()));

    result = context.resolveExpressionRef("Last12").getExpression().evaluate(context);
    assertThat(result, is(2));

    result = context.resolveExpressionRef("LastDateTime").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2014, 12, 10})));

    result = context.resolveExpressionRef("LastTime").getExpression().evaluate(context);
    assertThat(((Time)result).getPartial(), is(new Partial(Time.getFields(4), new int[] {20, 59, 59, 999})));
}
项目:cql_engine    文件:CqlDateTimeOperatorsTest.java   
/**
 * {@link org.opencds.cqf.cql.elm.execution.DateTimeEvaluator#evaluate(Context)}
 */
@Test
public void testDateTime() throws JAXBException {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("DateTimeYear").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(1), new int[] {2003})));

    result = context.resolveExpressionRef("DateTimeMonth").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(2), new int[] {2003, 10})));

    result = context.resolveExpressionRef("DateTimeDay").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2003, 10, 29})));

    result = context.resolveExpressionRef("DateTimeHour").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(4), new int[] {2003, 10, 29, 20})));

    result = context.resolveExpressionRef("DateTimeMinute").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(5), new int[] {2003, 10, 29, 20, 50})));

    result = context.resolveExpressionRef("DateTimeSecond").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(6), new int[] {2003, 10, 29, 20, 50, 33})));

    result = context.resolveExpressionRef("DateTimeMillisecond").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(7), new int[] {2003, 10, 29, 20, 50, 33, 955})));
}
项目:cql_engine    文件:CqlDateTimeOperatorsTest.java   
/**
 * {@link org.opencds.cqf.cql.elm.execution.TodayEvaluator#evaluate(Context)}
 */
@Test
public void testToday() throws JAXBException {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("DateTimeSameOrBeforeTodayTrue1").getExpression().evaluate(context);
    assertThat(result, is(true));

    result = context.resolveExpressionRef("DateTimeSameOrBeforeTodayTrue2").getExpression().evaluate(context);
    assertThat(result, is(true));

    result = context.resolveExpressionRef("DateTimeSameOrBeforeTodayFalse").getExpression().evaluate(context);
    assertThat(result, is(false));

    result = context.resolveExpressionRef("DateTimeAddTodayTrue").getExpression().evaluate(context);
    assertThat(result, is(true));

    context = new Context(library, new DateTime(new Partial(DateTime.getFields(7), new int[] {2016, 6, 10, 5, 5, 4, 999}), DateTimeZone.forOffsetHours(-7)));
    result = context.resolveExpressionRef("Issue34B").getExpression().evaluate(context);
    assertThat(((DateTime) result).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2016, 6, 10})));
    assertThat(((DateTime) result).getTimezoneOffset(), is(new BigDecimal("-7.00")));
}
项目:cql_engine    文件:CqlIntervalOperatorsTest.java   
/**
 * {@link org.opencds.cqf.cql.elm.execution.StartEvaluator#evaluate(Context)}
 */
@Test
public void TestStart() {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("IntegerIntervalStart").getExpression().evaluate(context);
    assertThat(result, is(1));

    result = context.resolveExpressionRef("DecimalIntervalStart").getExpression().evaluate(context);
    assertThat(result, is(new BigDecimal("1.0")));

    result = context.resolveExpressionRef("QuantityIntervalStart").getExpression().evaluate(context);
    Assert.assertTrue(((Quantity) result).equal(new Quantity().withValue(new BigDecimal("1.0")).withUnit("g")));

    result = context.resolveExpressionRef("DateTimeIntervalStart").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(7), new int[] {2016, 5, 1, 0, 0, 0, 0})));

    result = context.resolveExpressionRef("TimeIntervalStart").getExpression().evaluate(context);
    assertThat(((Time)result).getPartial(), is(new Partial(Time.getFields(4), new int[] {0, 0, 0, 0})));
}
项目:cql_engine    文件:CqlIntervalOperatorsTest.java   
/**
 * {@link org.opencds.cqf.cql.elm.execution.EndEvaluator#evaluate(Context)}
 */
@Test
public void TestEnd() {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("IntegerIntervalEnd").getExpression().evaluate(context);
    assertThat(result, is(10));

    result = context.resolveExpressionRef("DecimalIntervalEnd").getExpression().evaluate(context);
    assertThat(result, is(new BigDecimal("10.0")));

    result = context.resolveExpressionRef("QuantityIntervalEnd").getExpression().evaluate(context);
    Assert.assertTrue(((Quantity) result).equal(new Quantity().withValue(new BigDecimal("10.0")).withUnit("g")));

    result = context.resolveExpressionRef("DateTimeIntervalEnd").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(7), new int[] {2016, 5, 2, 0, 0, 0, 0})));

    result = context.resolveExpressionRef("TimeIntervalEnd").getExpression().evaluate(context);
    assertThat(((Time)result).getPartial(), is(new Partial(Time.getFields(4), new int[] {23, 59, 59, 599})));
}
项目:cql_engine    文件:CqlAggregateFunctionsTest.java   
/**
 * {@link org.opencds.cqf.cql.elm.execution.MaxEvaluator#evaluate(Context)}
 */
@Test
public void testMax() throws JAXBException {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("MaxTestInteger").getExpression().evaluate(context);
    assertThat(result, is(90));

    result = context.resolveExpressionRef("MaxTestString").getExpression().evaluate(context);
    assertThat(result, is("zebra"));

    result = context.resolveExpressionRef("MaxTestDateTime").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2012, 10, 6})));

    result = context.resolveExpressionRef("MaxTestTime").getExpression().evaluate(context);
    assertThat(((Time)result).getPartial(), is(new Partial(Time.getFields(4), new int[] {20, 59, 59, 999})));
}
项目:cql_engine    文件:CqlAggregateFunctionsTest.java   
/**
 * {@link org.opencds.cqf.cql.elm.execution.MinEvaluator#evaluate(Context)}
 */
@Test
public void testMin() throws JAXBException {
    Context context = new Context(library);

    Object result = context.resolveExpressionRef("MinTestInteger").getExpression().evaluate(context);
    assertThat(result, is(0));

    result = context.resolveExpressionRef("MinTestString").getExpression().evaluate(context);
    assertThat(result, is("bye"));

    result = context.resolveExpressionRef("MinTestDateTime").getExpression().evaluate(context);
    assertThat(((DateTime)result).getPartial(), is(new Partial(DateTime.getFields(3), new int[] {2012, 9, 5})));

    result = context.resolveExpressionRef("MinTestTime").getExpression().evaluate(context);
    assertThat(((Time)result).getPartial(), is(new Partial(Time.getFields(4), new int[] {5, 59, 59, 999})));
}
项目:trolley-tracker-android-client    文件:ScheduledRoute.java   
public ScheduledRoute(RouteSchedule rs) {
    schedule = rs;

    DateTime now = DateTime.now();
    Partial dayPartial = new Partial().with(DateTimeFieldType.dayOfWeek(), Constants.DayOfWeek.valueOf(rs.DayOfWeek).ordinal() + 1);
    DateTime startDay = Utils.rollForwardWith(now, dayPartial);

    DateTime schedStartDate = DateTime.parse(rs.DayOfWeek + " " + rs.StartTime, INPUT_DATE_FORMAT);
    DateTime schedEndDate = DateTime.parse(rs.DayOfWeek + " " + rs.EndTime, INPUT_DATE_FORMAT);

    DateTime nextStart = startDay
            .withTime(schedStartDate.getHourOfDay(), schedStartDate.getMinuteOfHour(), 0, 0);
    DateTime nextEnd = startDay
            .withTime(schedEndDate.getHourOfDay(), schedEndDate.getMinuteOfHour(), 0, 0);

    dayOfWeek = nextStart.getDayOfWeek();
    interval = new Interval(nextStart, nextEnd);
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_calBased_YMD_unmodifiable() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.year(),
            DateTimeFieldType.monthOfYear(),
            DateTimeFieldType.dayOfMonth(),
    };
    int[] values = new int[] {2005, 6, 25};
    List types = Collections.unmodifiableList(new ArrayList(Arrays.asList(fields)));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("2005-06-25", f.print(new Partial(fields, values)));
    assertEquals(3, types.size());

    types = Arrays.asList(fields);
    f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("2005-06-25", f.print(new Partial(fields, values)));
    assertEquals(3, types.size());
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_calBased_YMD_duplicates() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.year(),
            DateTimeFieldType.monthOfYear(),
            DateTimeFieldType.dayOfMonth(),
    };
    DateTimeFieldType[] dupFields = new DateTimeFieldType[] {
            DateTimeFieldType.year(),
            DateTimeFieldType.monthOfYear(),
            DateTimeFieldType.dayOfMonth(),
            DateTimeFieldType.monthOfYear(),
    };
    int[] values = new int[] {2005, 6, 25};
    List types = new ArrayList(Arrays.asList(dupFields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("2005-06-25", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = Arrays.asList(dupFields);
    f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("2005-06-25", f.print(new Partial(fields, values)));
    assertEquals(4, types.size());
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_calBased_Y() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.year(),
    };
    int[] values = new int[] {2005};
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("2005", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("2005", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("2005", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("2005", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_calBased_M() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.monthOfYear(),
    };
    int[] values = new int[] {6};
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("--06", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("--06", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("--06", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("--06", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_calBased_D() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.dayOfMonth(),
    };
    int[] values = new int[] {25};
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("---25", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("---25", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("---25", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("---25", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_calBased_YM() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.year(),
            DateTimeFieldType.monthOfYear(),
    };
    int[] values = new int[] {2005, 6};
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("2005-06", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("2005-06", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("2005-06", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("2005-06", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_calBased_MD() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.monthOfYear(),
            DateTimeFieldType.dayOfMonth(),
    };
    int[] values = new int[] {6, 25};
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("--06-25", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("--06-25", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("--0625", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("--0625", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_weekBased_Y() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.weekyear(),
    };
    int[] values = new int[] {2005};
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("2005", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("2005", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("2005", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("2005", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_weekBased_W() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.weekOfWeekyear(),
    };
    int[] values = new int[] {8};
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("-W08", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("-W08", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("-W08", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("-W08", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_weekBased_D() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.dayOfWeek(),
    };
    int[] values = new int[] {5};
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("-W-5", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("-W-5", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("-W-5", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("-W-5", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_weekBased_YW() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.weekyear(),
            DateTimeFieldType.weekOfWeekyear(),
    };
    int[] values = new int[] {2005, 8};
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("2005-W08", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("2005-W08", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("2005W08", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("2005W08", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_weekBased_WD() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.weekOfWeekyear(),
            DateTimeFieldType.dayOfWeek(),
    };
    int[] values = new int[] {8, 5};
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("-W08-5", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("-W08-5", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("-W085", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("-W085", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_ordinalBased_YD() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.year(),
            DateTimeFieldType.dayOfYear(),
    };
    int[] values = new int[] {2005, 177};
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("2005-177", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("2005-177", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("2005177", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("2005177", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_ordinalBased_Y() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.year(),
    };
    int[] values = new int[] {2005};
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("2005", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("2005", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("2005", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("2005", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_ordinalBased_D() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.dayOfYear(),
    };
    int[] values = new int[] {177};
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("-177", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("-177", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("-177", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("-177", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_time_HM() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.hourOfDay(),
            DateTimeFieldType.minuteOfHour(),
    };
    int[] values = new int[] {10, 20};
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("10:20", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("10:20", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("1020", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("1020", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_time_H() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.hourOfDay(),
    };
    int[] values = new int[] {10};
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("10", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("10", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("10", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("10", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_time_MS() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.minuteOfHour(),
            DateTimeFieldType.secondOfMinute(),
    };
    int[] values = new int[] {20, 30};
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("-20:30", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("-20:30", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("-2030", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("-2030", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_time_M() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.minuteOfHour(),
    };
    int[] values = new int[] {20};
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("-20", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("-20", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("-20", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("-20", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_time_Sm() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.secondOfMinute(),
            DateTimeFieldType.millisOfSecond(),
    };
    int[] values = new int[] {30, 40};
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("--30.040", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("--30.040", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("--30.040", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("--30.040", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}
项目:astor    文件:TestISODateTimeFormat_Fields.java   
public void testForFields_time_S() {
    DateTimeFieldType[] fields = new DateTimeFieldType[] {
            DateTimeFieldType.secondOfMinute(),
    };
    int[] values = new int[] {30};
    List types = new ArrayList(Arrays.asList(fields));
    DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
    assertEquals("--30", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, true, false);
    assertEquals("--30", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, true);
    assertEquals("--30", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());

    types = new ArrayList(Arrays.asList(fields));
    f = ISODateTimeFormat.forFields(types, false, false);
    assertEquals("--30", f.print(new Partial(fields, values)));
    assertEquals(0, types.size());
}