org.joda.time.TimeOfDay Java Examples
The following examples show how to use
org.joda.time.TimeOfDay.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestPreciseDateTimeField.java From astor with GNU General Public License v2.0 | 6 votes |
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)); }
Example #2
Source File: TestPersistentLocalTimeAsMillisInteger.java From jadira with Apache License 2.0 | 6 votes |
@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()); }
Example #3
Source File: TestBaseDateTimeField.java From astor with GNU General Public License v2.0 | 6 votes |
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)); }
Example #4
Source File: TestPreciseDurationDateTimeField.java From astor with GNU General Public License v2.0 | 6 votes |
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)); }
Example #5
Source File: TestPreciseDateTimeField.java From astor with GNU General Public License v2.0 | 6 votes |
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)); }
Example #6
Source File: TestCalendarConverter.java From astor with GNU General Public License v2.0 | 5 votes |
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)); }
Example #7
Source File: TestConverterManager.java From astor with GNU General Public License v2.0 | 5 votes |
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) {} }
Example #8
Source File: TimestampColumnTimeOfDayMapper.java From jadira with Apache License 2.0 | 5 votes |
@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; }
Example #9
Source File: EventSpaceOccupation.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
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; }
Example #10
Source File: StringColumnTimeOfDayMapper.java From jadira with Apache License 2.0 | 5 votes |
@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); } }
Example #11
Source File: TestGJChronology.java From astor with GNU General Public License v2.0 | 5 votes |
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)); }
Example #12
Source File: TestConverterManager.java From astor with GNU General Public License v2.0 | 5 votes |
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) {} }
Example #13
Source File: TestISOChronology.java From astor with GNU General Public License v2.0 | 5 votes |
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)); }
Example #14
Source File: TimeColumnTimeOfDayMapper.java From jadira with Apache License 2.0 | 5 votes |
@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; }
Example #15
Source File: TestCalendarConverter.java From astor with GNU General Public License v2.0 | 5 votes |
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)); }
Example #16
Source File: TimeColumnTimeOfDayMapper.java From jadira with Apache License 2.0 | 5 votes |
@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; }
Example #17
Source File: TimeOfDayAsStringHolder.java From jadira with Apache License 2.0 | 4 votes |
public void setLocalTime(TimeOfDay localTime) { this.localTime = localTime; }
Example #18
Source File: TestPreciseDurationDateTimeField.java From astor with GNU General Public License v2.0 | 4 votes |
public void test_getAsText_RP_Locale() { BaseDateTimeField field = new MockPreciseDurationDateTimeField(); assertEquals("40", field.getAsText(new TimeOfDay(12, 30, 40, 50), Locale.ENGLISH)); assertEquals("40", field.getAsText(new TimeOfDay(12, 30, 40, 50), null)); }
Example #19
Source File: TestPreciseDurationDateTimeField.java From astor with GNU General Public License v2.0 | 4 votes |
public void test_getAsShortText_RP_int_Locale() { BaseDateTimeField field = new MockPreciseDurationDateTimeField(); assertEquals("20", field.getAsShortText(new TimeOfDay(12, 30, 40, 50), 20, Locale.ENGLISH)); assertEquals("20", field.getAsShortText(new TimeOfDay(12, 30, 40, 50), 20, null)); }
Example #20
Source File: TestPreciseDateTimeField.java From astor with GNU General Public License v2.0 | 4 votes |
public void test_getMinimumValue_RP() { BaseDateTimeField field = new MockPreciseDateTimeField(); assertEquals(0, field.getMinimumValue(new TimeOfDay())); }
Example #21
Source File: TestPreciseDurationDateTimeField.java From astor with GNU General Public License v2.0 | 4 votes |
public void test_getAsText_RP_int_Locale() { BaseDateTimeField field = new MockPreciseDurationDateTimeField(); assertEquals("20", field.getAsText(new TimeOfDay(12, 30, 40, 50), 20, Locale.ENGLISH)); assertEquals("20", field.getAsText(new TimeOfDay(12, 30, 40, 50), 20, null)); }
Example #22
Source File: TimeOfDayAsTimeJoda.java From jadira with Apache License 2.0 | 4 votes |
public TimeOfDay getTimeOfDay() { return timeOfDay; }
Example #23
Source File: TestBaseDateTimeField.java From astor with GNU General Public License v2.0 | 4 votes |
public void test_getAsText_RP_Locale() { BaseDateTimeField field = new MockBaseDateTimeField(); assertEquals("40", field.getAsText(new TimeOfDay(12, 30, 40, 50), Locale.ENGLISH)); assertEquals("40", field.getAsText(new TimeOfDay(12, 30, 40, 50), null)); }
Example #24
Source File: TestNullConverter.java From astor with GNU General Public License v2.0 | 4 votes |
public void testGetPartialValues() throws Exception { TimeOfDay tod = new TimeOfDay(); int[] expected = new int[] {10 + 1, 20, 30, 40}; // now int[] actual = NullConverter.INSTANCE.getPartialValues(tod, null, ISOChronology.getInstance()); assertEquals(true, Arrays.equals(expected, actual)); }
Example #25
Source File: IntegerColumnTimeOfDayMapper.java From jadira with Apache License 2.0 | 4 votes |
@Override public TimeOfDay fromNonNullValue(Integer value) { return TimeOfDay.fromMillisOfDay(value); }
Example #26
Source File: TestReadablePartialConverter.java From astor with GNU General Public License v2.0 | 4 votes |
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)); }
Example #27
Source File: LongColumnTimeOfDayMapper.java From jadira with Apache License 2.0 | 4 votes |
@Override public TimeOfDay fromNonNullValue(Long value) { return new TimeOfDay(value / 1000000L, ISOChronology.getInstance(DateTimeZone.UTC)); }
Example #28
Source File: IntegerColumnTimeOfDayMapper.java From jadira with Apache License 2.0 | 4 votes |
@Override public String toNonNullString(TimeOfDay value) { return value.toString(); }
Example #29
Source File: TestBaseDateTimeField.java From astor with GNU General Public License v2.0 | 4 votes |
public void test_getAsShortText_RP_Locale() { BaseDateTimeField field = new MockBaseDateTimeField(); assertEquals("40", field.getAsShortText(new TimeOfDay(12, 30, 40, 50), Locale.ENGLISH)); assertEquals("40", field.getAsShortText(new TimeOfDay(12, 30, 40, 50), null)); }
Example #30
Source File: StringColumnTimeOfDayMapper.java From jadira with Apache License 2.0 | 4 votes |
@Override public TimeOfDay fromNonNullValue(String s) { return new TimeOfDay(s); }