本文整理汇总了Java中java.time.OffsetDateTime.getYear方法的典型用法代码示例。如果您正苦于以下问题:Java OffsetDateTime.getYear方法的具体用法?Java OffsetDateTime.getYear怎么用?Java OffsetDateTime.getYear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.OffsetDateTime
的用法示例。
在下文中一共展示了OffsetDateTime.getYear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeGeneralizedTime
import java.time.OffsetDateTime; //导入方法依赖的package包/类
public static int writeGeneralizedTime(Date time, byte[] out, int offset) {
OffsetDateTime offsetTime = time.toInstant().atOffset(ZoneOffset.UTC);
int idx = offset;
out[idx++] = 0x18;
out[idx++] = 15;
// yyyyMMddhhmmssZ
// year
int year = offsetTime.getYear();
out[idx++] = (byte) (0x30 + year / 1000);
out[idx++] = (byte) (0x30 + year / 100 % 10);
out[idx++] = (byte) (0x30 + year / 10 % 10);
out[idx++] = (byte) (0x30 + year % 10);
// month
int month = offsetTime.getMonthValue();
out[idx++] = (byte) (0x30 + month / 10);
out[idx++] = (byte) (0x30 + month % 10);
// day
int day = offsetTime.getDayOfMonth();
out[idx++] = (byte) (0x30 + day / 10);
out[idx++] = (byte) (0x30 + day % 10);
// hour
int hour = offsetTime.getHour();
out[idx++] = (byte) (0x30 + hour / 10);
out[idx++] = (byte) (0x30 + hour % 10);
// minute
int minute = offsetTime.getMinute();
out[idx++] = (byte) (0x30 + minute / 10);
out[idx++] = (byte) (0x30 + minute % 10);
// second
int second = offsetTime.getSecond();
out[idx++] = (byte) (0x30 + second / 10);
out[idx++] = (byte) (0x30 + second % 10);
out[idx++] = 'Z';
return idx - offset;
}
示例2: LocalTime
import java.time.OffsetDateTime; //导入方法依赖的package包/类
public LocalTime(OffsetDateTime offsetDateTime, Locale locale) {
offset = offsetDateTime.getOffset().getTotalSeconds();
year = offsetDateTime.getYear();
month = offsetDateTime.getMonth().getDisplayName(TextStyle.FULL,locale);
dayOfMonth = offsetDateTime.getDayOfMonth();
dayOfWeek = offsetDateTime.getDayOfWeek().getDisplayName(TextStyle.FULL,locale);
monthValue = offsetDateTime.getMonthValue();
hour = offsetDateTime.getHour();
minute = offsetDateTime.getMinute();
second = offsetDateTime.getSecond();
nano = offsetDateTime.getNano();
}
示例3: initImageCreationTime
import java.time.OffsetDateTime; //导入方法依赖的package包/类
void initImageCreationTime(OffsetDateTime offsetDateTime) {
// Check for incoming arguments
if (offsetDateTime != null) {
// set values that make up Standard/Document/ImageCreationTime
creation_time_present = true;
creation_time_year = offsetDateTime.getYear();
creation_time_month = offsetDateTime.getMonthValue();
creation_time_day = offsetDateTime.getDayOfMonth();
creation_time_hour = offsetDateTime.getHour();
creation_time_minute = offsetDateTime.getMinute();
creation_time_second = offsetDateTime.getSecond();
creation_time_offset = offsetDateTime.getOffset();
}
}
示例4: formatDate
import java.time.OffsetDateTime; //导入方法依赖的package包/类
public String formatDate(OffsetDateTime date) {
return date.getMonthValue() + "/" + date.getDayOfMonth() + "/" + date.getYear();
}