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


Java LocalDate.ofEpochDay方法代码示例

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


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

示例1: toNativeTypeInternal

import java.time.LocalDate; //导入方法依赖的package包/类
@Override
LocalDate toNativeTypeInternal(Object input) {
  if (input instanceof String) {
    return LocalDate.parse((String) input);
  } else if (input instanceof Number) {
    return LocalDate.ofEpochDay(((Number) input).longValue());
  }
  return null;
}
 
开发者ID:datastax,项目名称:simulacron,代码行数:10,代码来源:CqlMapper.java

示例2: decodeInternal

import java.time.LocalDate; //导入方法依赖的package包/类
@Override
LocalDate decodeInternal(ByteBuffer input) {
  if (input == null || input.remaining() == 0) return null;
  int unsigned = cint.decode(input);
  int signed = unsigned + Integer.MIN_VALUE;
  return LocalDate.ofEpochDay(signed);
}
 
开发者ID:datastax,项目名称:simulacron,代码行数:8,代码来源:CqlMapper.java

示例3: _randomClientBirthDate

import java.time.LocalDate; //导入方法依赖的package包/类
/**Returns a random birth date ranging from 18 years before now to 100 years before now.*/
private LocalDate _randomClientBirthDate() {
	final long nowEpochDay = LocalDate.now().toEpochDay();
	final int minYears = 18;
	final int maxYears = 100;
	final long minEpochDay = nowEpochDay - 365*maxYears;
	final long maxEpochDay = nowEpochDay - 365*minYears;
	//See https://stackoverflow.com/questions/34051291/generate-a-random-localdate-with-java-time
    final long randomEpochDay = ThreadLocalRandom.current().nextLong(minEpochDay, maxEpochDay);
    return LocalDate.ofEpochDay(randomEpochDay);
}
 
开发者ID:ChristophKnabe,项目名称:spring-ddd-bank,代码行数:12,代码来源:ApplicationController.java

示例4: main

import java.time.LocalDate; //导入方法依赖的package包/类
/**
 * 程序执行入口.
 *
 * @param args 命令行参数
 */
public static void main(String[] args) {

	LocalDate today = LocalDate.now(); // |\longremark{获取当前日期}|
	System.out.println("Current Date=" + today);

	LocalDate firstDay2016 = LocalDate.of(2016, 1, 1); // |\longremark{给定年月日创建特定日期对象}|
	System.out.println("Specific Date=" + firstDay2016);


	//LocalDate feb29_2014 = LocalDate.of(2014, Month.FEBRUARY, 29); // |\longremark{给定日期不合法}|
	//Current date in "Asia/Shanghai", you can get it from ZoneId javadoc
	LocalDate todayShanghai = LocalDate.now(ZoneId.of("Asia/Shanghai")); // |\longremark{根据时区获取当前日期}|
	System.out.println("Current Date in CST=" + todayShanghai);


	//LocalDate todayIST = LocalDate.now(ZoneId.of("IST")); // |\longremark{给定时区不合法}|
	LocalDate dateFromBase = LocalDate.ofEpochDay(365); // |\longremark{从1970-1-1开始计算}|
	System.out.println("365th day from base date= " + dateFromBase);

	LocalDate hundredDay2016 = LocalDate.ofYearDay(2016, 100); // |\longremark{从给定年份开始计算}|
	System.out.println("100th day of 2016=" + hundredDay2016);

	LocalDate one = LocalDate.parse("2016-11-21"); //|\longremark{将字符串解析为LocalDate对象}|
	LocalDate two = LocalDate.parse("2016-11-22");
	System.out.println("2016-11-21 parsed to LocalDate = " + one);
	System.out.println("2016-11-21 < 2016-11-22 ? " + one.isBefore(two));
	System.out.println("2016-11-21 < 2016-11-21 ? " + one.isBefore(one));
	System.out.println("2016-11-22 > 2016-11-21 ? " + two.isAfter(one));
}
 
开发者ID:subaochen,项目名称:java-tutorial,代码行数:35,代码来源:LocalDateTest.java

示例5: queryFrom

import java.time.LocalDate; //导入方法依赖的package包/类
@Override
public LocalDate queryFrom(TemporalAccessor temporal) {
    if (temporal.isSupported(EPOCH_DAY)) {
        return LocalDate.ofEpochDay(temporal.getLong(EPOCH_DAY));
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:TemporalQueries.java

示例6: getTradeDate

import java.time.LocalDate; //导入方法依赖的package包/类
@Override
public LocalDate getTradeDate() {
  long millis = readWord(8);
  return LocalDate.ofEpochDay(millis);
}
 
开发者ID:kogupta,项目名称:scala-playground,代码行数:6,代码来源:BinaryTrade.java

示例7: getSettlementDate

import java.time.LocalDate; //导入方法依赖的package包/类
@Override
public LocalDate getSettlementDate() {
  long millis = readWord(37);
  return LocalDate.ofEpochDay(millis);
}
 
开发者ID:kogupta,项目名称:scala-playground,代码行数:6,代码来源:BinaryTrade.java

示例8: DatePgData

import java.time.LocalDate; //导入方法依赖的package包/类
public DatePgData() {
    super(PgDataType.DATE,
            LocalDate.ofEpochDay(0),
            LocalDate.of(2070, 1, 1),
            LocalDate.ofEpochDay(1));
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:7,代码来源:DatePgData.java

示例9: factory_ofEpochDay_aboveMax

import java.time.LocalDate; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void factory_ofEpochDay_aboveMax() {
    LocalDate.ofEpochDay(MAX_VALID_EPOCHDAYS + 1);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:TCKLocalDate.java

示例10: factory_ofEpochDay_belowMin

import java.time.LocalDate; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void factory_ofEpochDay_belowMin() {
    LocalDate.ofEpochDay(MIN_VALID_EPOCHDAYS - 1);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:TCKLocalDate.java

示例11: getValue

import java.time.LocalDate; //导入方法依赖的package包/类
@Override
public final LocalDate getValue(long code) {
    return code == Long.MIN_VALUE ? null : LocalDate.ofEpochDay(code);
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:5,代码来源:LongCoding.java

示例12: dateEpochDay

import java.time.LocalDate; //导入方法依赖的package包/类
/**
 * Obtains a local date in the Japanese calendar system from the epoch-day.
 *
 * @param epochDay  the epoch day
 * @return the Japanese local date, not null
 * @throws DateTimeException if unable to create the date
 */
@Override  // override with covariant return type
public JapaneseDate dateEpochDay(long epochDay) {
    return new JapaneseDate(LocalDate.ofEpochDay(epochDay));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:JapaneseChronology.java

示例13: dateEpochDay

import java.time.LocalDate; //导入方法依赖的package包/类
/**
 * Obtains a local date in the Minguo calendar system from the epoch-day.
 *
 * @param epochDay  the epoch day
 * @return the Minguo local date, not null
 * @throws DateTimeException if unable to create the date
 */
@Override  // override with covariant return type
public MinguoDate dateEpochDay(long epochDay) {
    return new MinguoDate(LocalDate.ofEpochDay(epochDay));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:MinguoChronology.java

示例14: getRandomDate

import java.time.LocalDate; //导入方法依赖的package包/类
/**
 * Get the random date that falls between 1-Jan-1900 and 31-Dec-2100.
 * 
 * @return the date
 */
public static final LocalDate getRandomDate() {
  return LocalDate.ofEpochDay(BEG_DAY + Math.abs(RANDOM.nextInt(DAYS_RANGE)));
}
 
开发者ID:ampool,项目名称:monarch,代码行数:9,代码来源:RandomDataGenerator.java

示例15: getRandomDate

import java.time.LocalDate; //导入方法依赖的package包/类
/**
 * Get the random date that falls between 1-Jan-1900 and 31-Dec-2100.
 *
 * @return the date
 */
public static final LocalDate getRandomDate() {
  return LocalDate.ofEpochDay(BEG_DAY + Math.abs(RANDOM.nextInt(DAYS_RANGE)));
}
 
开发者ID:ampool,项目名称:monarch,代码行数:9,代码来源:TypeUtils.java


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