本文整理汇总了Java中org.joda.time.TimeOfDay类的典型用法代码示例。如果您正苦于以下问题:Java TimeOfDay类的具体用法?Java TimeOfDay怎么用?Java TimeOfDay使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimeOfDay类属于org.joda.time包,在下文中一共展示了TimeOfDay类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:23,代码来源:TestPreciseDurationDateTimeField.java
示例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));
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:23,代码来源:TestPreciseDateTimeField.java
示例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));
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:TestOffsetDateTimeField.java
示例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));
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:23,代码来源:TestBaseDateTimeField.java
示例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;
}
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:20,代码来源:LessonInstanceSpaceOccupation.java
示例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());
}
开发者ID:JadiraOrg,项目名称:jadira,代码行数:27,代码来源:TestPersistentLocalTimeAsMillisInteger.java
示例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());
}
开发者ID:JadiraOrg,项目名称:jadira,代码行数:26,代码来源:TestPersistentTimeOfDay.java
示例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());
}
}
开发者ID:mosscode,项目名称:joda-swing,代码行数:21,代码来源:JodaOptionPane.java
示例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));
}
开发者ID:FlexTradeUKLtd,项目名称:jfixture,代码行数:9,代码来源:TestAllClassDataTypesAreSupported.java
示例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));
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:9,代码来源:TestCalendarConverter.java
示例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) {}
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:28,代码来源:TestConverterManager.java
示例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));
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:9,代码来源:TestGJChronology.java
示例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));
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:9,代码来源:TestISOChronology.java
示例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;
}
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:39,代码来源:EventSpaceOccupation.java
示例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);
}
}
开发者ID:JadiraOrg,项目名称:jadira,代码行数:13,代码来源:StringColumnTimeOfDayMapper.java
示例16: fromNonNullValue
import org.joda.time.TimeOfDay; //导入依赖的package包/类
@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;
}
开发者ID:JadiraOrg,项目名称:jadira,代码行数:10,代码来源:TimestampColumnTimeOfDayMapper.java
示例17: toNonNullValue
import org.joda.time.TimeOfDay; //导入依赖的package包/类
@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;
}
开发者ID:JadiraOrg,项目名称:jadira,代码行数:11,代码来源:TimestampColumnTimeOfDayMapper.java
示例18: fromNonNullValue
import org.joda.time.TimeOfDay; //导入依赖的package包/类
@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;
}
开发者ID:JadiraOrg,项目名称:jadira,代码行数:10,代码来源:TimeColumnTimeOfDayMapper.java
示例19: toNonNullValue
import org.joda.time.TimeOfDay; //导入依赖的package包/类
@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;
}
开发者ID:JadiraOrg,项目名称:jadira,代码行数:11,代码来源:TimeColumnTimeOfDayMapper.java
示例20: testGetPartialValues
import org.joda.time.TimeOfDay; //导入依赖的package包/类
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));
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:7,代码来源:TestDateConverter.java
注:本文中的org.joda.time.TimeOfDay类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论