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