當前位置: 首頁>>代碼示例>>Java>>正文


Java LocalTime.ofSecondOfDay方法代碼示例

本文整理匯總了Java中java.time.LocalTime.ofSecondOfDay方法的典型用法代碼示例。如果您正苦於以下問題:Java LocalTime.ofSecondOfDay方法的具體用法?Java LocalTime.ofSecondOfDay怎麽用?Java LocalTime.ofSecondOfDay使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.time.LocalTime的用法示例。


在下文中一共展示了LocalTime.ofSecondOfDay方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readExternal

import java.time.LocalTime; //導入方法依賴的package包/類
/**
 * Reads the state from the stream.
 *
 * @param in  the input stream, not null
 * @return the created object, not null
 * @throws IOException if an error occurs
 */
static ZoneOffsetTransitionRule readExternal(DataInput in) throws IOException {
    int data = in.readInt();
    Month month = Month.of(data >>> 28);
    int dom = ((data & (63 << 22)) >>> 22) - 32;
    int dowByte = (data & (7 << 19)) >>> 19;
    DayOfWeek dow = dowByte == 0 ? null : DayOfWeek.of(dowByte);
    int timeByte = (data & (31 << 14)) >>> 14;
    TimeDefinition defn = TimeDefinition.values()[(data & (3 << 12)) >>> 12];
    int stdByte = (data & (255 << 4)) >>> 4;
    int beforeByte = (data & (3 << 2)) >>> 2;
    int afterByte = (data & 3);
    LocalTime time = (timeByte == 31 ? LocalTime.ofSecondOfDay(in.readInt()) : LocalTime.of(timeByte % 24, 0));
    ZoneOffset std = (stdByte == 255 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds((stdByte - 128) * 900));
    ZoneOffset before = (beforeByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + beforeByte * 1800));
    ZoneOffset after = (afterByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + afterByte * 1800));
    return ZoneOffsetTransitionRule.of(month, dom, dow, time, timeByte == 24, defn, std, before, after);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:25,代碼來源:ZoneOffsetTransitionRule.java

示例2: main

import java.time.LocalTime; //導入方法依賴的package包/類
/**
 * 程序執行入口.
 *
 * @param args 命令行參數
 */
public static void main(String[] args) {

    LocalTime time = LocalTime.now();// |\longremark{獲取當前時間}|
    System.out.println("Current Time=" + time);

    LocalTime specificTime = LocalTime.of(12, 20, 25, 40); // |\longremark{根據給定時間創建時間對象}|
    System.out.println("Specific Time of Day=" + specificTime);

    LocalTime timeShanghai = LocalTime.now(ZoneId.of("Asia/Shanghai")); // |\longremark{根據給定時區創建時間對象}|
    System.out.println("Current Time in CST=" + timeShanghai);

    //Getting date from the base date i.e 01/01/1970
    LocalTime specificSecondTime = LocalTime.ofSecondOfDay(10000);// |\longremark{獲得從1970-1-1開始計算的時間}|
    System.out.println("10000th second time= " + specificSecondTime);

    LocalTime one = LocalTime.parse("12:30:55"); //|\longremark{將字符串解析為LocalTime對象}|
    LocalTime two = LocalTime.parse("13:02:15");
    //LocalTime three = LocalTime.parse("2016-1-1 13:02:15"); // 格式錯誤
    System.out.println("12:30:55 parsed to LocalDate = " + one);
    System.out.println("12:30:55 < 13:02:15 ? " + one.isBefore(two));
    System.out.println("12:30:55 < 12:30:55 ? " + one.isBefore(one));
    System.out.println("13:02:15 > 12:30:55 ? " + two.isAfter(one));
}
 
開發者ID:subaochen,項目名稱:java-tutorial,代碼行數:29,代碼來源:LocalTimeTest.java

示例3: factory_ofSecondOfDay_singletons

import java.time.LocalTime; //導入方法依賴的package包/類
@Test
public void factory_ofSecondOfDay_singletons() {
    for (int i = 0; i < 24; i++) {
        LocalTime test1 = LocalTime.ofSecondOfDay(i * 60L * 60L);
        LocalTime test2 = LocalTime.of(i, 0);
        assertSame(test1, test2);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:9,代碼來源:TestLocalTime.java

示例4: second

import java.time.LocalTime; //導入方法依賴的package包/類
public static Time second(int seconds) {
	LocalDate date = LocalDate.ofYearDay(0, asStartDays(seconds));
	LocalTime time = LocalTime.ofSecondOfDay(asSecondsAtDay(seconds));
	return new Time(LocalDateTime.of(date, time));
}
 
開發者ID:mobitopp,項目名稱:connection-scan,代碼行數:6,代碼來源:Data.java

示例5: factory_ofSecondOfDay

import java.time.LocalTime; //導入方法依賴的package包/類
@Test
public void factory_ofSecondOfDay() {
    LocalTime localTime = LocalTime.ofSecondOfDay(2 * 60 * 60 + 17 * 60 + 23);
    check(localTime, 2, 17, 23, 0);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:6,代碼來源:TCKLocalTime.java

示例6: factory_ofSecondOfDay_tooLow

import java.time.LocalTime; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeException.class)
public void factory_ofSecondOfDay_tooLow() {
    LocalTime.ofSecondOfDay(-1);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:5,代碼來源:TCKLocalTime.java

示例7: factory_ofSecondOfDay_tooHigh

import java.time.LocalTime; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeException.class)
public void factory_ofSecondOfDay_tooHigh() {
    LocalTime.ofSecondOfDay(24 * 60 * 60);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:5,代碼來源:TCKLocalTime.java

示例8: getRandomTime

import java.time.LocalTime; //導入方法依賴的package包/類
/**
 * Get the random time of day in seconds.
 * 
 * @return the time in seconds
 */
public static final LocalTime getRandomTime() {
  return LocalTime.ofSecondOfDay(getRandomInt(DAY_SECONDS));
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:9,代碼來源:RandomDataGenerator.java

示例9: getRandomTime

import java.time.LocalTime; //導入方法依賴的package包/類
/**
 * Get the random time of day in seconds.
 *
 * @return the time in seconds
 */
public static final LocalTime getRandomTime() {
  return LocalTime.ofSecondOfDay(getRandomInt(DAY_SECONDS));
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:9,代碼來源:TypeUtils.java


注:本文中的java.time.LocalTime.ofSecondOfDay方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。