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


Java LocalTime.toSecondOfDay方法代码示例

本文整理汇总了Java中java.time.LocalTime.toSecondOfDay方法的典型用法代码示例。如果您正苦于以下问题:Java LocalTime.toSecondOfDay方法的具体用法?Java LocalTime.toSecondOfDay怎么用?Java LocalTime.toSecondOfDay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.LocalTime的用法示例。


在下文中一共展示了LocalTime.toSecondOfDay方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: draw

import java.time.LocalTime; //导入方法依赖的package包/类
public void draw() {
    final double width = getWidth();
    final double height = getHeight();

    GraphicsContext gc = getGraphicsContext2D();
    gc.clearRect(0, 0, width, height);

    if (entries != null && !entries.isEmpty()) {
        for (Entry<?> entry : entries) {
            com.calendarfx.model.Calendar calendar = entry.getCalendar();
            if (calendar == null) {
                continue;
            }

            Color color = getCalendarColor(calendar.getStyle());
            gc.setFill(color);

            if (entry.isFullDay()) {
                gc.fillRect(0, 0, width, height);
            } else {
                LocalTime startTime = entry.getStartTime();
                LocalTime endTime = entry.getEndTime();

                if (entry.getStartDate().isBefore(getDate())) {
                    startTime = LocalTime.MIN;
                }

                if (entry.getEndDate().isAfter(getDate())) {
                    endTime = LocalTime.MAX;
                }

                double y = height * (startTime.toSecondOfDay() / (double) LocalTime.MAX.toSecondOfDay());
                double h = height * (endTime.toSecondOfDay() / (double) LocalTime.MAX.toSecondOfDay());
                gc.fillRect(0, y, width, h - y);
            }
        }
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:39,代码来源:MonthSheetView.java

示例2: writeRule

import java.time.LocalTime; //导入方法依赖的package包/类
/**
 * Writes the state of the transition rule to the stream.
 *
 * @param rule  the transition rule, not null
 * @param out  the output stream, not null
 * @throws IOException if an error occurs
 */
static void writeRule(ZoneOffsetTransitionRule rule, DataOutput out) throws IOException {
    int month = rule.getMonth().getValue();
    byte dom = (byte)rule.getDayOfMonthIndicator();
    int dow = (rule.getDayOfWeek() == null ? -1 : rule.getDayOfWeek().getValue());
    LocalTime time = rule.getLocalTime();
    boolean timeEndOfDay = rule.isMidnightEndOfDay();
    TimeDefinition timeDefinition = rule.getTimeDefinition();
    ZoneOffset standardOffset = rule.getStandardOffset();
    ZoneOffset offsetBefore = rule.getOffsetBefore();
    ZoneOffset offsetAfter = rule.getOffsetAfter();

    int timeSecs = (timeEndOfDay ? 86400 : time.toSecondOfDay());
    int stdOffset = standardOffset.getTotalSeconds();
    int beforeDiff = offsetBefore.getTotalSeconds() - stdOffset;
    int afterDiff = offsetAfter.getTotalSeconds() - stdOffset;
    int timeByte = (timeSecs % 3600 == 0 ? (timeEndOfDay ? 24 : time.getHour()) : 31);
    int stdOffsetByte = (stdOffset % 900 == 0 ? stdOffset / 900 + 128 : 255);
    int beforeByte = (beforeDiff == 0 || beforeDiff == 1800 || beforeDiff == 3600 ? beforeDiff / 1800 : 3);
    int afterByte = (afterDiff == 0 || afterDiff == 1800 || afterDiff == 3600 ? afterDiff / 1800 : 3);
    int dowByte = (dow == -1 ? 0 : dow);
    int b = (month << 28) +                     // 4 bytes
            ((dom + 32) << 22) +                // 6 bytes
            (dowByte << 19) +                   // 3 bytes
            (timeByte << 14) +                  // 5 bytes
            (timeDefinition.ordinal() << 12) +  // 2 bytes
            (stdOffsetByte << 4) +              // 8 bytes
            (beforeByte << 2) +                 // 2 bytes
            afterByte;                          // 2 bytes
    out.writeInt(b);
    if (timeByte == 31) {
        out.writeInt(timeSecs);
    }
    if (stdOffsetByte == 255) {
        out.writeInt(stdOffset);
    }
    if (beforeByte == 3) {
        out.writeInt(offsetBefore.getTotalSeconds());
    }
    if (afterByte == 3) {
        out.writeInt(offsetAfter.getTotalSeconds());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:50,代码来源:ZoneRules.java


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