當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。