本文整理汇总了Java中java.time.OffsetDateTime.format方法的典型用法代码示例。如果您正苦于以下问题:Java OffsetDateTime.format方法的具体用法?Java OffsetDateTime.format怎么用?Java OffsetDateTime.format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.OffsetDateTime
的用法示例。
在下文中一共展示了OffsetDateTime.format方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: offsetDateTimeCompatibilityWithDateTimeFormatter
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test
public void offsetDateTimeCompatibilityWithDateTimeFormatter() throws Exception {
final OffsetDateTime out = OffsetDateTime.now();
final String s = out.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
final OffsetDateTime in = VPackJdk8Deserializers.OFFSET_DATE_TIME.deserialize(null,
new VPackBuilder().add(s).slice(), null);
assertThat(in, is(out));
}
示例3: convert
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Override
public String convert(OffsetDateTime source) {
return source.format(FORMATTER);
}