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

项目:astor    文件:TestPreciseDurationDateTimeField.java   
public void test_addWrapField_RP_int_intarray_int() {
    BaseDateTimeField field = new MockPreciseDurationDateTimeField();
    int[] values = new int[] {10, 20, 30, 40};
    int[] expected = new int[] {10, 20, 30, 40};
    int[] result = field.addWrapField(new TimeOfDay(), 2, values, 0);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 59, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 29);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 0, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 30);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 1, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 31);
    assertEquals(true, Arrays.equals(result, expected));
}
项目:astor    文件:TestPreciseDateTimeField.java   
public void test_addWrapField_RP_int_intarray_int() {
    BaseDateTimeField field = new MockPreciseDateTimeField();
    int[] values = new int[] {10, 20, 30, 40};
    int[] expected = new int[] {10, 20, 30, 40};
    int[] result = field.addWrapField(new TimeOfDay(), 2, values, 0);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 59, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 29);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 0, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 30);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 1, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 31);
    assertEquals(true, Arrays.equals(result, expected));
}
项目:astor    文件:TestOffsetDateTimeField.java   
public void test_addWrapField_RP_int_intarray_int() {
    OffsetDateTimeField field = new MockOffsetDateTimeField();
    int[] values = new int[] {10, 20, 30, 40};
    int[] expected = new int[] {10, 20, 30, 40};
    int[] result = field.addWrapField(new TimeOfDay(), 2, values, 0);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 59, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 29);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 3, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 33);
    assertEquals(true, Arrays.equals(result, expected));
}
项目:astor    文件:TestBaseDateTimeField.java   
public void test_addWrapField_RP_int_intarray_int() {
    BaseDateTimeField field = new MockBaseDateTimeField();
    int[] values = new int[] {10, 20, 30, 40};
    int[] expected = new int[] {10, 20, 30, 40};
    int[] result = field.addWrapField(new TimeOfDay(), 2, values, 0);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 59, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 29);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 0, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 30);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 1, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 31);
    assertEquals(true, Arrays.equals(result, expected));
}
项目:astor    文件:TestPreciseDurationDateTimeField.java   
public void test_addWrapField_RP_int_intarray_int() {
    BaseDateTimeField field = new MockPreciseDurationDateTimeField();
    int[] values = new int[] {10, 20, 30, 40};
    int[] expected = new int[] {10, 20, 30, 40};
    int[] result = field.addWrapField(new TimeOfDay(), 2, values, 0);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 59, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 29);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 0, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 30);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 1, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 31);
    assertEquals(true, Arrays.equals(result, expected));
}
项目:astor    文件:TestPreciseDateTimeField.java   
public void test_addWrapField_RP_int_intarray_int() {
    BaseDateTimeField field = new MockPreciseDateTimeField();
    int[] values = new int[] {10, 20, 30, 40};
    int[] expected = new int[] {10, 20, 30, 40};
    int[] result = field.addWrapField(new TimeOfDay(), 2, values, 0);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 59, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 29);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 0, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 30);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 1, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 31);
    assertEquals(true, Arrays.equals(result, expected));
}
项目:astor    文件:TestOffsetDateTimeField.java   
public void test_addWrapField_RP_int_intarray_int() {
    OffsetDateTimeField field = new MockOffsetDateTimeField();
    int[] values = new int[] {10, 20, 30, 40};
    int[] expected = new int[] {10, 20, 30, 40};
    int[] result = field.addWrapField(new TimeOfDay(), 2, values, 0);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 59, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 29);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 3, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 33);
    assertEquals(true, Arrays.equals(result, expected));
}
项目:astor    文件:TestBaseDateTimeField.java   
public void test_addWrapField_RP_int_intarray_int() {
    BaseDateTimeField field = new MockBaseDateTimeField();
    int[] values = new int[] {10, 20, 30, 40};
    int[] expected = new int[] {10, 20, 30, 40};
    int[] result = field.addWrapField(new TimeOfDay(), 2, values, 0);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 59, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 29);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 0, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 30);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 1, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 31);
    assertEquals(true, Arrays.equals(result, expected));
}
项目:fenixedu-academic    文件:LessonInstanceSpaceOccupation.java   
@Override
public List<Interval> getEventSpaceOccupationIntervals(YearMonthDay startDateToSearch, YearMonthDay endDateToSearch) {

    List<Interval> result = new ArrayList<Interval>();
    Collection<LessonInstance> lessonInstances = getLessonInstancesSet();

    DateTime startDateTime = startDateToSearch != null ? startDateToSearch.toDateTimeAtMidnight() : null;
    DateTime endDateTime = endDateToSearch != null ? endDateToSearch.toDateTime(new TimeOfDay(23, 59, 59)) : null;

    for (LessonInstance lessonInstance : lessonInstances) {
        if (startDateTime == null
                || (!lessonInstance.getEndDateTime().isBefore(startDateTime) && !lessonInstance.getBeginDateTime().isAfter(
                        endDateTime))) {

            result.add(new Interval(lessonInstance.getBeginDateTime(), lessonInstance.getEndDateTime()));
        }
    }
    return result;
}
项目:jadira    文件:TestPersistentLocalTimeAsMillisInteger.java   
@Test
@Ignore
public void testNanosWithJodaTimeOfDay() {
    JodaLocalTimeAsMillisIntegerHolder item = new JodaLocalTimeAsMillisIntegerHolder();
    item.setId(1);
    item.setName("test_nanos1");
    item.setLocalTime(new LocalTime(10, 10, 10, 111));

    persist(item);


    TimeOfDayExactJoda jodaItem = find(TimeOfDayExactJoda.class, (long) 1);

    assertNotNull(jodaItem);
    assertEquals(1, jodaItem.getId());
    assertEquals("test_nanos1", jodaItem.getName());
    assertEquals(new TimeOfDay(10, 10, 10, 111), jodaItem.getTimeOfDay());


    item = find((long) 1);

    assertNotNull(item);
    assertEquals(1, item.getId());
    assertEquals("test_nanos1", item.getName());
    assertEquals(new LocalTime(10, 10, 10, 111), item.getLocalTime());
}
项目:jadira    文件:TestPersistentTimeOfDay.java   
@Test
@Ignore // This test will fail because Joda Time does not support nanosecond precision
public void testNanosWithJodaTime() {
    TimeOfDayHolder item = new TimeOfDayHolder();
    item.setId(1);
    item.setName("test_nanos1");
    item.setLocalTime(new TimeOfDay(10, 10, 10, 111444444));

    persist(item);

    TimeOfDayAsTimeJoda jodaItem = find(TimeOfDayAsTimeJoda.class, (long) 1);

    assertNotNull(jodaItem);
    assertEquals(1, jodaItem.getId());
    assertEquals("test_nanos1", jodaItem.getName());
    assertEquals(new TimeOfDay(10, 10, 10, 0), jodaItem.getTimeOfDay());


    item = find(TimeOfDayHolder.class, Long.valueOf(1));

    assertNotNull(item);
    assertEquals(1, item.getId());
    assertEquals("test_nanos1", item.getName());
    assertEquals(new TimeOfDay(10, 10, 10, 111444444), item.getLocalTime());
}
项目:joda-swing    文件:JodaOptionPane.java   
private static TimeOfDay parseTime(String text){
    if(text==null || text.trim().length()==0){
        return null;
    }
    else{
        DateTime paddedTime = null;
        for(DateTimeFormatter format: timeFormats){
            try{
                paddedTime = format.parseDateTime(text);
            }catch(IllegalArgumentException e){
                // just means the text is no good.
            }
        }

        if(paddedTime==null)
            throw new RuntimeException("Unparsable time: " + text);

        return new TimeOfDay(paddedTime.getHourOfDay(), paddedTime.getMinuteOfHour(), paddedTime.getSecondOfMinute());
    }
}
项目:versemem-android    文件:TestPreciseDurationDateTimeField.java   
public void test_addWrapField_RP_int_intarray_int() {
    BaseDateTimeField field = new MockPreciseDurationDateTimeField();
    int[] values = new int[] {10, 20, 30, 40};
    int[] expected = new int[] {10, 20, 30, 40};
    int[] result = field.addWrapField(new TimeOfDay(), 2, values, 0);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 59, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 29);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 0, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 30);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 1, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 31);
    assertEquals(true, Arrays.equals(result, expected));
}
项目:versemem-android    文件:TestPreciseDateTimeField.java   
public void test_addWrapField_RP_int_intarray_int() {
    BaseDateTimeField field = new MockPreciseDateTimeField();
    int[] values = new int[] {10, 20, 30, 40};
    int[] expected = new int[] {10, 20, 30, 40};
    int[] result = field.addWrapField(new TimeOfDay(), 2, values, 0);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 59, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 29);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 0, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 30);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 1, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 31);
    assertEquals(true, Arrays.equals(result, expected));
}
项目:versemem-android    文件:TestOffsetDateTimeField.java   
public void test_addWrapField_RP_int_intarray_int() {
    OffsetDateTimeField field = new MockOffsetDateTimeField();
    int[] values = new int[] {10, 20, 30, 40};
    int[] expected = new int[] {10, 20, 30, 40};
    int[] result = field.addWrapField(new TimeOfDay(), 2, values, 0);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 59, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 29);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 3, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 33);
    assertEquals(true, Arrays.equals(result, expected));
}
项目:versemem-android    文件:TestBaseDateTimeField.java   
public void test_addWrapField_RP_int_intarray_int() {
    BaseDateTimeField field = new MockBaseDateTimeField();
    int[] values = new int[] {10, 20, 30, 40};
    int[] expected = new int[] {10, 20, 30, 40};
    int[] result = field.addWrapField(new TimeOfDay(), 2, values, 0);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 59, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 29);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 0, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 30);
    assertEquals(true, Arrays.equals(result, expected));

    values = new int[] {10, 20, 30, 40};
    expected = new int[] {10, 20, 1, 40};
    result = field.addWrapField(new TimeOfDay(), 2, values, 31);
    assertEquals(true, Arrays.equals(result, expected));
}
项目:jfixture    文件:TestAllClassDataTypesAreSupported.java   
@Test
public void creates_instance_of_TimeOfDay() {
    TimeOfDay timeOfDay = fixture.create(TimeOfDay.class);
    assertThat(timeOfDay, notNullValue());
    assertThat(timeOfDay.getHourOfDay(), is(12));
    assertThat(timeOfDay.getMinuteOfHour(), is(34));
    assertThat(timeOfDay.getSecondOfMinute(), is(56));
}
项目:astor    文件:TestCalendarConverter.java   
public void testGetPartialValues() throws Exception {
    GregorianCalendar cal = new GregorianCalendar();
    cal.setTime(new Date(12345678L));
    TimeOfDay tod = new TimeOfDay();
    int[] expected = ISO.get(tod, 12345678L);
    int[] actual = CalendarConverter.INSTANCE.getPartialValues(tod, cal, ISO);
    assertEquals(true, Arrays.equals(expected, actual));
}
项目:astor    文件:TestConverterManager.java   
public void testGetPartialConverter() {
    PartialConverter c = ConverterManager.getInstance().getPartialConverter(new Long(0L));
    assertEquals(Long.class, c.getSupportedType());

    c = ConverterManager.getInstance().getPartialConverter(new TimeOfDay());
    assertEquals(ReadablePartial.class, c.getSupportedType());

    c = ConverterManager.getInstance().getPartialConverter(new DateTime());
    assertEquals(ReadableInstant.class, c.getSupportedType());

    c = ConverterManager.getInstance().getPartialConverter("");
    assertEquals(String.class, c.getSupportedType());

    c = ConverterManager.getInstance().getPartialConverter(new Date());
    assertEquals(Date.class, c.getSupportedType());

    c = ConverterManager.getInstance().getPartialConverter(new GregorianCalendar());
    assertEquals(Calendar.class, c.getSupportedType());

    c = ConverterManager.getInstance().getPartialConverter(null);
    assertEquals(null, c.getSupportedType());

    try {
        ConverterManager.getInstance().getPartialConverter(Boolean.TRUE);
        fail();
    } catch (IllegalArgumentException ex) {}
}
项目:astor    文件:TestGJChronology.java   
public void testTimeOfDayAdd() {
    TimeOfDay start = new TimeOfDay(12, 30, GJChronology.getInstance());
    TimeOfDay end = new TimeOfDay(10, 30, GJChronology.getInstance());
    assertEquals(end, start.plusHours(22));
    assertEquals(start, end.minusHours(22));
    assertEquals(end, start.plusMinutes(22 * 60));
    assertEquals(start, end.minusMinutes(22 * 60));
}
项目:astor    文件:TestISOChronology.java   
public void testTimeOfDayAdd() {
    TimeOfDay start = new TimeOfDay(12, 30);
    TimeOfDay end = new TimeOfDay(10, 30);
    assertEquals(end, start.plusHours(22));
    assertEquals(start, end.minusHours(22));
    assertEquals(end, start.plusMinutes(22 * 60));
    assertEquals(start, end.minusMinutes(22 * 60));
}
项目:astor    文件:TestCalendarConverter.java   
public void testGetPartialValues() throws Exception {
    GregorianCalendar cal = new GregorianCalendar();
    cal.setTime(new Date(12345678L));
    TimeOfDay tod = new TimeOfDay();
    int[] expected = ISO.get(tod, 12345678L);
    int[] actual = CalendarConverter.INSTANCE.getPartialValues(tod, cal, ISO);
    assertEquals(true, Arrays.equals(expected, actual));
}
项目:astor    文件:TestConverterManager.java   
public void testGetPartialConverter() {
    PartialConverter c = ConverterManager.getInstance().getPartialConverter(new Long(0L));
    assertEquals(Long.class, c.getSupportedType());

    c = ConverterManager.getInstance().getPartialConverter(new TimeOfDay());
    assertEquals(ReadablePartial.class, c.getSupportedType());

    c = ConverterManager.getInstance().getPartialConverter(new DateTime());
    assertEquals(ReadableInstant.class, c.getSupportedType());

    c = ConverterManager.getInstance().getPartialConverter("");
    assertEquals(String.class, c.getSupportedType());

    c = ConverterManager.getInstance().getPartialConverter(new Date());
    assertEquals(Date.class, c.getSupportedType());

    c = ConverterManager.getInstance().getPartialConverter(new GregorianCalendar());
    assertEquals(Calendar.class, c.getSupportedType());

    c = ConverterManager.getInstance().getPartialConverter(null);
    assertEquals(null, c.getSupportedType());

    try {
        ConverterManager.getInstance().getPartialConverter(Boolean.TRUE);
        fail();
    } catch (IllegalArgumentException ex) {}
}
项目:astor    文件:TestGJChronology.java   
public void testTimeOfDayAdd() {
    TimeOfDay start = new TimeOfDay(12, 30, GJChronology.getInstance());
    TimeOfDay end = new TimeOfDay(10, 30, GJChronology.getInstance());
    assertEquals(end, start.plusHours(22));
    assertEquals(start, end.minusHours(22));
    assertEquals(end, start.plusMinutes(22 * 60));
    assertEquals(start, end.minusMinutes(22 * 60));
}
项目:astor    文件:TestISOChronology.java   
public void testTimeOfDayAdd() {
    TimeOfDay start = new TimeOfDay(12, 30);
    TimeOfDay end = new TimeOfDay(10, 30);
    assertEquals(end, start.plusHours(22));
    assertEquals(start, end.minusHours(22));
    assertEquals(end, start.plusMinutes(22 * 60));
    assertEquals(start, end.minusMinutes(22 * 60));
}
项目:fenixedu-academic    文件:EventSpaceOccupation.java   
protected DateTime getInstant(boolean firstInstant, YearMonthDay begin, final YearMonthDay end,
        final HourMinuteSecond beginTime, final HourMinuteSecond endTime, final FrequencyType frequency,
        final DiaSemana diaSemana, final Boolean dailyFrequencyMarkSaturday, final Boolean dailyFrequencyMarkSunday) {

    DateTime instantResult = null;
    begin = getBeginDateInSpecificWeekDay(diaSemana, begin);

    if (frequency == null) {
        if (!begin.isAfter(end)) {
            if (firstInstant) {
                return begin.toDateTime(new TimeOfDay(beginTime.getHour(), beginTime.getMinuteOfHour(), 0, 0));
            } else {
                return end.toDateTime(new TimeOfDay(endTime.getHour(), endTime.getMinuteOfHour(), 0, 0));
            }
        }
    } else {
        int numberOfDaysToSum = frequency.getNumberOfDays();
        while (true) {
            if (begin.isAfter(end)) {
                break;
            }

            DateTime intervalEnd = begin.toDateTime(new TimeOfDay(endTime.getHour(), endTime.getMinuteOfHour(), 0, 0));
            if (!frequency.equals(FrequencyType.DAILY)
                    || ((dailyFrequencyMarkSaturday || intervalEnd.getDayOfWeek() != SATURDAY_IN_JODA_TIME) && (dailyFrequencyMarkSunday || intervalEnd
                            .getDayOfWeek() != SUNDAY_IN_JODA_TIME))) {

                if (firstInstant) {
                    return begin.toDateTime(new TimeOfDay(beginTime.getHour(), beginTime.getMinuteOfHour(), 0, 0));
                } else {
                    instantResult = intervalEnd;
                }
            }
            begin = begin.plusDays(numberOfDaysToSum);
        }
    }
    return instantResult;
}
项目:jadira    文件:StringColumnTimeOfDayMapper.java   
@Override
public String toNonNullValue(TimeOfDay value) {

    if (value.getMillisOfSecond() == 0) {
        if (value.getSecondOfMinute() == 0) {
            return Formatter.LOCAL_TIME_NOSECONDS_PRINTER.print(value);
        }
        return Formatter.LOCAL_TIME_NOMILLIS_PRINTER.print(value);
    } else {
        return value.toString().substring(1);
    }
}
项目:jadira    文件:TimestampColumnTimeOfDayMapper.java   
@Override
public TimeOfDay fromNonNullValue(Timestamp value) {

    DateTime dateTime = new DateTime(value.getTime());
    LocalTime localTime = dateTime.toLocalTime();

    final TimeOfDay timeOfDay = new TimeOfDay(localTime.getHourOfDay(), localTime.getMinuteOfHour(), localTime.getSecondOfMinute(), localTime.getMillisOfSecond(), localTime.getChronology());
    return timeOfDay;
}
项目:jadira    文件:TimestampColumnTimeOfDayMapper.java   
@Override
public Timestamp toNonNullValue(TimeOfDay value) {

    DateTime zonedValue = new LocalDateTime(
            1970,1,1,value.getHourOfDay(), value.getMinuteOfHour(), value.getSecondOfMinute(), value.getMillisOfSecond(), value.getChronology()
    ).toDateTime();

    final Timestamp timestamp = new Timestamp(zonedValue.getMillis());
    return timestamp;
}
项目:jadira    文件:TimeColumnTimeOfDayMapper.java   
@Override
public TimeOfDay fromNonNullValue(Time value) {

    DateTime dateTime = new DateTime(value.getTime());
    LocalTime localTime = dateTime.toLocalTime();

    final TimeOfDay timeOfDay = new TimeOfDay(localTime.getHourOfDay(), localTime.getMinuteOfHour(), localTime.getSecondOfMinute(), localTime.getMillisOfSecond(), localTime.getChronology());
    return timeOfDay;
}
项目:jadira    文件:TimeColumnTimeOfDayMapper.java   
@Override
public Time toNonNullValue(TimeOfDay value) {

    DateTime zonedValue = new LocalDateTime(
            1970,1,1,value.getHourOfDay(), value.getMinuteOfHour(), value.getSecondOfMinute(), value.getMillisOfSecond(), value.getChronology()
    ).toDateTime();

    final Time time = new Time(zonedValue.getMillis());
    return time;
}
项目:versemem-android    文件:TestCalendarConverter.java   
public void testGetPartialValues() throws Exception {
    GregorianCalendar cal = new GregorianCalendar();
    cal.setTime(new Date(12345678L));
    TimeOfDay tod = new TimeOfDay();
    int[] expected = ISO.get(tod, 12345678L);
    int[] actual = CalendarConverter.INSTANCE.getPartialValues(tod, cal, ISO);
    assertEquals(true, Arrays.equals(expected, actual));
}
项目:versemem-android    文件:TestConverterManager.java   
public void testGetPartialConverter() {
    PartialConverter c = ConverterManager.getInstance().getPartialConverter(new Long(0L));
    assertEquals(Long.class, c.getSupportedType());

    c = ConverterManager.getInstance().getPartialConverter(new TimeOfDay());
    assertEquals(ReadablePartial.class, c.getSupportedType());

    c = ConverterManager.getInstance().getPartialConverter(new DateTime());
    assertEquals(ReadableInstant.class, c.getSupportedType());

    c = ConverterManager.getInstance().getPartialConverter("");
    assertEquals(String.class, c.getSupportedType());

    c = ConverterManager.getInstance().getPartialConverter(new Date());
    assertEquals(Date.class, c.getSupportedType());

    c = ConverterManager.getInstance().getPartialConverter(new GregorianCalendar());
    assertEquals(Calendar.class, c.getSupportedType());

    c = ConverterManager.getInstance().getPartialConverter(null);
    assertEquals(null, c.getSupportedType());

    try {
        ConverterManager.getInstance().getPartialConverter(Boolean.TRUE);
        fail();
    } catch (IllegalArgumentException ex) {}
}
项目:versemem-android    文件:TestGJChronology.java   
public void testTimeOfDayAdd() {
    TimeOfDay start = new TimeOfDay(12, 30, GJChronology.getInstance());
    TimeOfDay end = new TimeOfDay(10, 30, GJChronology.getInstance());
    assertEquals(end, start.plusHours(22));
    assertEquals(start, end.minusHours(22));
    assertEquals(end, start.plusMinutes(22 * 60));
    assertEquals(start, end.minusMinutes(22 * 60));
}
项目:versemem-android    文件:TestISOChronology.java   
public void testTimeOfDayAdd() {
    TimeOfDay start = new TimeOfDay(12, 30);
    TimeOfDay end = new TimeOfDay(10, 30);
    assertEquals(end, start.plusHours(22));
    assertEquals(start, end.minusHours(22));
    assertEquals(end, start.plusMinutes(22 * 60));
    assertEquals(start, end.minusMinutes(22 * 60));
}
项目:astor    文件:TestDateConverter.java   
public void testGetPartialValues() throws Exception {
    TimeOfDay tod = new TimeOfDay();
    int[] expected = COPTIC.get(tod, 12345678L);
    int[] actual = DateConverter.INSTANCE.getPartialValues(tod, new Date(12345678L), COPTIC);
    assertEquals(true, Arrays.equals(expected, actual));
}
项目:astor    文件:TestLongConverter.java   
public void testGetPartialValues() throws Exception {
    TimeOfDay tod = new TimeOfDay();
    int[] expected = ISOChronology.getInstance().get(tod, 12345678L);
    int[] actual = LongConverter.INSTANCE.getPartialValues(tod, new Long(12345678L), ISOChronology.getInstance());
    assertEquals(true, Arrays.equals(expected, actual));
}
项目:astor    文件:TestReadablePartialConverter.java   
public void testGetChronology_Object_Zone() throws Exception {
    assertEquals(ISO_PARIS, ReadablePartialConverter.INSTANCE.getChronology(new TimeOfDay(123L), PARIS));
    assertEquals(ISO, ReadablePartialConverter.INSTANCE.getChronology(new TimeOfDay(123L), DateTimeZone.getDefault()));
    assertEquals(ISO, ReadablePartialConverter.INSTANCE.getChronology(new TimeOfDay(123L), (DateTimeZone) null));
}
项目:astor    文件:TestReadablePartialConverter.java   
public void testGetChronology_Object_Chronology() throws Exception {
    assertEquals(JULIAN, ReadablePartialConverter.INSTANCE.getChronology(new TimeOfDay(123L, BUDDHIST), JULIAN));
    assertEquals(JULIAN, ReadablePartialConverter.INSTANCE.getChronology(new TimeOfDay(123L), JULIAN));
    assertEquals(BUDDHIST.withUTC(), ReadablePartialConverter.INSTANCE.getChronology(new TimeOfDay(123L, BUDDHIST), (Chronology) null));
}
项目:astor    文件:TestReadableInstantConverter.java   
public void testGetPartialValues() throws Exception {
    TimeOfDay tod = new TimeOfDay();
    int[] expected = ISOChronology.getInstance().get(tod, 12345678L);
    int[] actual = ReadableInstantConverter.INSTANCE.getPartialValues(tod, new Instant(12345678L), ISOChronology.getInstance());
    assertEquals(true, Arrays.equals(expected, actual));
}