本文整理汇总了Java中org.joda.time.TimeOfDay类的典型用法代码示例。如果您正苦于以下问题:Java TimeOfDay类的具体用法?Java TimeOfDay怎么用?Java TimeOfDay使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimeOfDay类属于org.joda.time包,在下文中一共展示了TimeOfDay类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_addWrapField_RP_int_intarray_int
import org.joda.time.TimeOfDay; //导入依赖的package包/类
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));
}
示例2: test_addWrapField_RP_int_intarray_int
import org.joda.time.TimeOfDay; //导入依赖的package包/类
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));
}
示例3: test_addWrapField_RP_int_intarray_int
import org.joda.time.TimeOfDay; //导入依赖的package包/类
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));
}
示例4: test_addWrapField_RP_int_intarray_int
import org.joda.time.TimeOfDay; //导入依赖的package包/类
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));
}
示例5: getEventSpaceOccupationIntervals
import org.joda.time.TimeOfDay; //导入依赖的package包/类
@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;
}
示例6: testNanosWithJodaTimeOfDay
import org.joda.time.TimeOfDay; //导入依赖的package包/类
@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());
}
示例7: testNanosWithJodaTime
import org.joda.time.TimeOfDay; //导入依赖的package包/类
@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());
}
示例8: parseTime
import org.joda.time.TimeOfDay; //导入依赖的package包/类
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());
}
}
示例9: creates_instance_of_TimeOfDay
import org.joda.time.TimeOfDay; //导入依赖的package包/类
@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));
}
示例10: testGetPartialValues
import org.joda.time.TimeOfDay; //导入依赖的package包/类
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));
}
示例11: testGetPartialConverter
import org.joda.time.TimeOfDay; //导入依赖的package包/类
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) {}
}
示例12: testTimeOfDayAdd
import org.joda.time.TimeOfDay; //导入依赖的package包/类
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));
}
示例13: testTimeOfDayAdd
import org.joda.time.TimeOfDay; //导入依赖的package包/类
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));
}
示例14: getInstant
import org.joda.time.TimeOfDay; //导入依赖的package包/类
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;
}
示例15: toNonNullValue
import org.joda.time.TimeOfDay; //导入依赖的package包/类
@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);
}
}