当前位置: 首页>>代码示例>>Java>>正文


Java OffsetDateTime.getYear方法代码示例

本文整理汇总了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;
}
 
开发者ID:xipki,项目名称:xitk,代码行数:36,代码来源:ASN1Type.java

示例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();
}
 
开发者ID:graphhopper,项目名称:timezone,代码行数:13,代码来源:LocalTime.java

示例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();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:PNGMetadata.java

示例4: formatDate

import java.time.OffsetDateTime; //导入方法依赖的package包/类
public String formatDate(OffsetDateTime date) {
    return date.getMonthValue() + "/" + date.getDayOfMonth() + "/" + date.getYear();
}
 
开发者ID:Rubicon-Bot,项目名称:Rubicon,代码行数:4,代码来源:CommandUserInfo.java


注:本文中的java.time.OffsetDateTime.getYear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。