当前位置: 首页>>代码示例>>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;未经允许,请勿转载。