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


Java LocalDate.ofYearDay方法代碼示例

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


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

示例1: 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

示例2: second

import java.time.LocalDate; //導入方法依賴的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

示例3: factory_ofYearDay_ints_yearTooLow

import java.time.LocalDate; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeException.class)
public void factory_ofYearDay_ints_yearTooLow() {
    LocalDate.ofYearDay(Integer.MIN_VALUE, 1);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:TCKLocalDate.java

示例4: factory_ofYearDay_ints_dayTooHigh

import java.time.LocalDate; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeException.class)
public void factory_ofYearDay_ints_dayTooHigh() {
    LocalDate.ofYearDay(2007, 367);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:TCKLocalDate.java

示例5: factory_ofYearDay_ints_366nonLeap

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

示例6: factory_ofYearDay_ints_dayTooLow

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

示例7: dateYearDay

import java.time.LocalDate; //導入方法依賴的package包/類
/**
 * Obtains an ISO local date from the proleptic-year and day-of-year fields.
 * <p>
 * This is equivalent to {@link LocalDate#ofYearDay(int, int)}.
 * 
 * @param prolepticYear the ISO proleptic-year
 * @param dayOfYear the ISO day-of-year
 * @return the ISO local date, not null
 * @throws DateTimeException if unable to create the date
 */
@Override
// override with covariant return type
public LocalDate dateYearDay(int prolepticYear, int dayOfYear) {

  return LocalDate.ofYearDay(prolepticYear, dayOfYear);
}
 
開發者ID:kiegroup,項目名稱:optashift-employee-rostering,代碼行數:17,代碼來源:ISOChrono.java

示例8: dateYearDay

import java.time.LocalDate; //導入方法依賴的package包/類
/**
 * Obtains an ISO local date from the proleptic-year and day-of-year fields.
 * <p>
 * This is equivalent to {@link LocalDate#ofYearDay(int, int)}.
 *
 * @param prolepticYear  the ISO proleptic-year
 * @param dayOfYear  the ISO day-of-year
 * @return the ISO local date, not null
 * @throws DateTimeException if unable to create the date
 */
@Override  // override with covariant return type
public LocalDate dateYearDay(int prolepticYear, int dayOfYear) {
    return LocalDate.ofYearDay(prolepticYear, dayOfYear);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:15,代碼來源:IsoChronology.java

示例9: dateYearDay

import java.time.LocalDate; //導入方法依賴的package包/類
/**
 * Obtains a local date in Japanese calendar system from the
 * proleptic-year and day-of-year fields.
 * <p>
 * The day-of-year in this factory is expressed relative to the start of the proleptic year.
 * The Japanese proleptic year and day-of-year are the same as those in the ISO calendar system.
 * They are not reset when the era changes.
 *
 * @param prolepticYear  the proleptic-year
 * @param dayOfYear  the day-of-year
 * @return the Japanese local date, not null
 * @throws DateTimeException if unable to create the date
 */
@Override
public JapaneseDate dateYearDay(int prolepticYear, int dayOfYear) {
    return new JapaneseDate(LocalDate.ofYearDay(prolepticYear, dayOfYear));
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:JapaneseChronology.java

示例10: dateYearDay

import java.time.LocalDate; //導入方法依賴的package包/類
/**
 * Obtains a local date in Minguo calendar system from the
 * proleptic-year and day-of-year fields.
 *
 * @param prolepticYear  the proleptic-year
 * @param dayOfYear  the day-of-year
 * @return the Minguo local date, not null
 * @throws DateTimeException if unable to create the date
 */
@Override
public MinguoDate dateYearDay(int prolepticYear, int dayOfYear) {
    return new MinguoDate(LocalDate.ofYearDay(prolepticYear + YEARS_DIFFERENCE, dayOfYear));
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:14,代碼來源:MinguoChronology.java

示例11: dateYearDay

import java.time.LocalDate; //導入方法依賴的package包/類
/**
 * Obtains a local date in Thai Buddhist calendar system from the
 * proleptic-year and day-of-year fields.
 *
 * @param prolepticYear  the proleptic-year
 * @param dayOfYear  the day-of-year
 * @return the Thai Buddhist local date, not null
 * @throws DateTimeException if unable to create the date
 */
@Override
public ThaiBuddhistDate dateYearDay(int prolepticYear, int dayOfYear) {
    return new ThaiBuddhistDate(LocalDate.ofYearDay(prolepticYear - YEARS_DIFFERENCE, dayOfYear));
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:14,代碼來源:ThaiBuddhistChronology.java


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