本文整理汇总了Java中java.time.OffsetDateTime.of方法的典型用法代码示例。如果您正苦于以下问题:Java OffsetDateTime.of方法的具体用法?Java OffsetDateTime.of怎么用?Java OffsetDateTime.of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.OffsetDateTime
的用法示例。
在下文中一共展示了OffsetDateTime.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encodeImageCreationTimeToTextChunk
import java.time.OffsetDateTime; //导入方法依赖的package包/类
void encodeImageCreationTimeToTextChunk() {
// Check if Standard/Document/ImageCreationTime exists.
if (creation_time_present) {
// Check if a text chunk with creation time exists.
if (tEXt_creation_time_present == false) {
// No text chunk exists with image creation time. Add an entry.
this.tEXt_keyword.add(tEXt_creationTimeKey);
this.tEXt_text.add("Creation Time Place Holder");
// Update the iterator
int index = tEXt_text.size() - 1;
setCreationTimeChunk(tEXt_text.listIterator(index));
}
// Encode image creation time with RFC1123 formatter
OffsetDateTime offDateTime = OffsetDateTime.of(creation_time_year,
creation_time_month, creation_time_day,
creation_time_hour, creation_time_minute,
creation_time_second, 0, creation_time_offset);
DateTimeFormatter formatter = DateTimeFormatter.RFC_1123_DATE_TIME;
String encodedTime = offDateTime.format(formatter);
setEncodedTime(encodedTime);
}
}
示例2: save_and_load_willResultInSameValue
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test
public void save_and_load_willResultInSameValue() {
OffsetDateTime original = OffsetDateTime.of(2017, 8, 29, 3, 9, 36, 0, ZoneOffset.ofHours(10));
Date date = save(original);
OffsetDateTime loaded = load(date)
.withOffsetSameInstant(ZoneOffset.ofHours(10));
assertThat(loaded, equalTo(original));
}
开发者ID:3wks,项目名称:generator-thundr-gae-react,代码行数:11,代码来源:OffsetDateTimeDateTranslatorFactoryTest.java
示例3: test_compareTo_min
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test
public void test_compareTo_min() {
OffsetDateTime a = OffsetDateTime.of(Year.MIN_VALUE, 1, 1, 0, 0, 0, 0, OFFSET_PTWO);
OffsetDateTime b = OffsetDateTime.of(Year.MIN_VALUE, 1, 1, 0, 0, 0, 0, OFFSET_PONE); // a is before b due to offset
assertEquals(a.compareTo(b) < 0, true);
assertEquals(b.compareTo(a) > 0, true);
assertEquals(a.compareTo(a) == 0, true);
assertEquals(b.compareTo(b) == 0, true);
}
示例4: test_equals_false_second_differs
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test(dataProvider="sampleTimes")
public void test_equals_false_second_differs(int y, int o, int d, int h, int m, int s, int n, ZoneOffset ignored) {
s = (s == 59 ? 58 : s);
OffsetDateTime a = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PONE);
OffsetDateTime b = OffsetDateTime.of(y, o, d, h, m, s + 1, n, OFFSET_PONE);
assertEquals(a.equals(b), false);
}
示例5: data_localDateTime
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@DataProvider(name="localDateTime")
Object[][] data_localDateTime() {
return new Object[][] {
{LocalDateTime.of(2012, 2, 29, 2, 7), HijrahChronology.INSTANCE.date(1433, 4, 7), LocalTime.of(2, 7), null},
{ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_RIYADH), HijrahChronology.INSTANCE.date(1433, 4, 7), LocalTime.of(2, 7, 1, 1), null},
{OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO), HijrahChronology.INSTANCE.date(1433, 4, 7), LocalTime.of(2, 7, 1, 1), null},
{JapaneseDate.of(2012, 2, 29), null, null, DateTimeException.class},
{ThaiBuddhistDate.of(2012 + 543, 2, 29), null, null, DateTimeException.class},
{LocalDate.of(2012, 2, 29), null, null, DateTimeException.class},
{LocalTime.of(20, 30, 29, 0), null, null, DateTimeException.class},
};
}
示例6: factory_of_LocalDateLocalTimeZoneOffset
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test
public void factory_of_LocalDateLocalTimeZoneOffset() {
LocalDate date = LocalDate.of(2008, 6, 30);
LocalTime time = LocalTime.of(11, 30, 10, 500);
OffsetDateTime test = OffsetDateTime.of(date, time, OFFSET_PONE);
check(test, 2008, 6, 30, 11, 30, 10, 500, OFFSET_PONE);
}
示例7: test_with_adjustment
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test
public void test_with_adjustment() {
final OffsetDateTime sample = OffsetDateTime.of(LocalDate.of(2012, 3, 4), LocalTime.of(23, 5), OFFSET_PONE);
TemporalAdjuster adjuster = new TemporalAdjuster() {
@Override
public Temporal adjustInto(Temporal dateTime) {
return sample;
}
};
assertEquals(TEST_2008_6_30_11_30_59_000000500.with(adjuster), sample);
}
示例8: test_compareTo_timeMins
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test
public void test_compareTo_timeMins() {
OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 29, 3, 0, OFFSET_PONE);
OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 30, 2, 0, OFFSET_PONE); // a is before b due to time
assertEquals(a.compareTo(b) < 0, true);
assertEquals(b.compareTo(a) > 0, true);
assertEquals(a.compareTo(a) == 0, true);
assertEquals(b.compareTo(b) == 0, true);
assertEquals(a.toInstant().compareTo(b.toInstant()) < 0, true);
assertEquals(OffsetDateTime.timeLineOrder().compare(a, b) < 0, true);
}
示例9: test_compareTo_max
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test
public void test_compareTo_max() {
OffsetDateTime a = OffsetDateTime.of(Year.MAX_VALUE, 12, 31, 23, 59, 0, 0, OFFSET_MONE);
OffsetDateTime b = OffsetDateTime.of(Year.MAX_VALUE, 12, 31, 23, 59, 0, 0, OFFSET_MTWO); // a is before b due to offset
assertEquals(a.compareTo(b) < 0, true);
assertEquals(b.compareTo(a) > 0, true);
assertEquals(a.compareTo(a) == 0, true);
assertEquals(b.compareTo(b) == 0, true);
}
示例10: test_compareTo_offsetNanos
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test
public void test_compareTo_offsetNanos() {
OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 40, 6, OFFSET_PTWO);
OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 30, 40, 5, OFFSET_PONE); // a is before b due to offset
assertEquals(a.compareTo(b) < 0, true);
assertEquals(b.compareTo(a) > 0, true);
assertEquals(a.compareTo(a) == 0, true);
assertEquals(b.compareTo(b) == 0, true);
assertEquals(a.toInstant().compareTo(b.toInstant()) < 0, true);
assertEquals(OffsetDateTime.timeLineOrder().compare(a, b) < 0, true);
}
示例11: test_compareTo_timeNanos
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test
public void test_compareTo_timeNanos() {
OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 29, 40, 4, OFFSET_PONE);
OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 29, 40, 5, OFFSET_PONE); // a is before b due to time
assertEquals(a.compareTo(b) < 0, true);
assertEquals(b.compareTo(a) > 0, true);
assertEquals(a.compareTo(a) == 0, true);
assertEquals(b.compareTo(b) == 0, true);
assertEquals(a.toInstant().compareTo(b.toInstant()) < 0, true);
assertEquals(OffsetDateTime.timeLineOrder().compare(a, b) < 0, true);
}
示例12: test_minusYears
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test
public void test_minusYears() {
OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
OffsetDateTime test = base.minusYears(1);
assertEquals(test, OffsetDateTime.of(2007, 6, 30, 11, 30, 59, 0, OFFSET_PONE));
}
示例13: test_withMonth_normal
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test
public void test_withMonth_normal() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
OffsetDateTime test = base.withMonth(1);
assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 1, 30), LocalTime.of(11, 30, 59), OFFSET_PONE));
}
示例14: test_plusMonths_zero
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test
public void test_plusMonths_zero() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
OffsetDateTime test = base.plusMonths(0);
assertSame(test, base);
}
示例15: data_format_withZone_withChronology
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@DataProvider(name="formatWithZoneWithChronology")
Object[][] data_format_withZone_withChronology() {
YearMonth ym = YearMonth.of(2008, 6);
LocalDate ld = LocalDate.of(2008, 6, 30);
LocalTime lt = LocalTime.of(11, 30);
LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 11, 30);
OffsetTime ot = OffsetTime.of(LocalTime.of(11, 30), OFFSET_PONE);
OffsetDateTime odt = OffsetDateTime.of(LocalDateTime.of(2008, 6, 30, 11, 30), OFFSET_PONE);
ZonedDateTime zdt = ZonedDateTime.of(LocalDateTime.of(2008, 6, 30, 11, 30), ZONE_PARIS);
ChronoZonedDateTime<ThaiBuddhistDate> thaiZdt = ThaiBuddhistChronology.INSTANCE.zonedDateTime(zdt);
Instant instant = Instant.ofEpochSecond(3600);
return new Object[][] {
{null, null, DayOfWeek.MONDAY, "::::"},
{null, null, ym, "2008::::ISO"},
{null, null, ld, "2008::::ISO"},
{null, null, lt, ":11:::"},
{null, null, ldt, "2008:11:::ISO"},
{null, null, ot, ":11:+01:00::"},
{null, null, odt, "2008:11:+01:00::ISO"},
{null, null, zdt, "2008:11:+02:00:Europe/Paris:ISO"},
{null, null, instant, "::::"},
{IsoChronology.INSTANCE, null, DayOfWeek.MONDAY, "::::ISO"},
{IsoChronology.INSTANCE, null, ym, "2008::::ISO"},
{IsoChronology.INSTANCE, null, ld, "2008::::ISO"},
{IsoChronology.INSTANCE, null, lt, ":11:::ISO"},
{IsoChronology.INSTANCE, null, ldt, "2008:11:::ISO"},
{IsoChronology.INSTANCE, null, ot, ":11:+01:00::ISO"},
{IsoChronology.INSTANCE, null, odt, "2008:11:+01:00::ISO"},
{IsoChronology.INSTANCE, null, zdt, "2008:11:+02:00:Europe/Paris:ISO"},
{IsoChronology.INSTANCE, null, instant, "::::ISO"},
{null, ZONE_PARIS, DayOfWeek.MONDAY, ":::Europe/Paris:"},
{null, ZONE_PARIS, ym, "2008:::Europe/Paris:ISO"},
{null, ZONE_PARIS, ld, "2008:::Europe/Paris:ISO"},
{null, ZONE_PARIS, lt, ":11::Europe/Paris:"},
{null, ZONE_PARIS, ldt, "2008:11::Europe/Paris:ISO"},
{null, ZONE_PARIS, ot, ":11:+01:00:Europe/Paris:"},
{null, ZONE_PARIS, odt, "2008:12:+02:00:Europe/Paris:ISO"},
{null, ZONE_PARIS, zdt, "2008:11:+02:00:Europe/Paris:ISO"},
{null, ZONE_PARIS, instant, "1970:02:+01:00:Europe/Paris:ISO"},
{null, OFFSET_PTHREE, DayOfWeek.MONDAY, ":::+03:00:"},
{null, OFFSET_PTHREE, ym, "2008:::+03:00:ISO"},
{null, OFFSET_PTHREE, ld, "2008:::+03:00:ISO"},
{null, OFFSET_PTHREE, lt, ":11::+03:00:"},
{null, OFFSET_PTHREE, ldt, "2008:11::+03:00:ISO"},
{null, OFFSET_PTHREE, ot, null}, // offset and zone clash
{null, OFFSET_PTHREE, odt, "2008:13:+03:00:+03:00:ISO"},
{null, OFFSET_PTHREE, zdt, "2008:12:+03:00:+03:00:ISO"},
{null, OFFSET_PTHREE, instant, "1970:04:+03:00:+03:00:ISO"},
{ThaiBuddhistChronology.INSTANCE, null, DayOfWeek.MONDAY, null}, // not a complete date
{ThaiBuddhistChronology.INSTANCE, null, ym, null}, // not a complete date
{ThaiBuddhistChronology.INSTANCE, null, ld, "2551::::ThaiBuddhist"},
{ThaiBuddhistChronology.INSTANCE, null, lt, ":11:::ThaiBuddhist"},
{ThaiBuddhistChronology.INSTANCE, null, ldt, "2551:11:::ThaiBuddhist"},
{ThaiBuddhistChronology.INSTANCE, null, ot, ":11:+01:00::ThaiBuddhist"},
{ThaiBuddhistChronology.INSTANCE, null, odt, "2551:11:+01:00::ThaiBuddhist"},
{ThaiBuddhistChronology.INSTANCE, null, zdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"},
{ThaiBuddhistChronology.INSTANCE, null, instant, "::::ThaiBuddhist"},
{ThaiBuddhistChronology.INSTANCE, null, DayOfWeek.MONDAY, null}, // not a complete date
{ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ym, null}, // not a complete date
{ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ld, "2551:::Europe/Paris:ThaiBuddhist"},
{ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, lt, ":11::Europe/Paris:ThaiBuddhist"},
{ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ldt, "2551:11::Europe/Paris:ThaiBuddhist"},
{ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ot, ":11:+01:00:Europe/Paris:ThaiBuddhist"},
{ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, odt, "2551:12:+02:00:Europe/Paris:ThaiBuddhist"},
{ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, zdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"},
{ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, instant, "2513:02:+01:00:Europe/Paris:ThaiBuddhist"},
{null, ZONE_PARIS, thaiZdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"},
{ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, thaiZdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"},
{IsoChronology.INSTANCE, ZONE_PARIS, thaiZdt, "2008:11:+02:00:Europe/Paris:ISO"},
};
}