当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Java ThaiBuddhistChronology dateYearDay(Era, int, int)用法及代码示例


java.time.chrono.ThaiBuddhistChronology类的dateYearDay()方法用于根据特定时代的ThaiBuddhist日历检索ThaiBuddhist日期。

用法:

public ThaiBuddhistDate dateYearDay(
  Era era, int yearOfEra, int dayOfYear)

参数:此方法采用以下参数作为参数:



  • era:这是类型时代的对象
  • year:这是ThaiBuddhistDate的year字段的整数年份
  • day:这是ThaiBuddhistDate的day字段的整数天

返回值:此方法根据特定年份和日期的ThaiBuddhist日历返回ThaiBuddhist日期。

异常:如果给定数据无法形成日期,则此方法引发DateTimeException。

下面是说明dateYearDay()方法的示例:

范例1:

Java

// Java program to demonstrate 
// dateYearDay() method 
  
import java.util.*; 
import java.io.*; 
import java.time.*; 
import java.time.chrono.*; 
  
public class GFG { 
    public static void main(String[] argv) 
    { 
        try { 
            // creating and initializing 
            // ThaiBuddhistDate Object 
            ThaiBuddhistDate hidate 
                = ThaiBuddhistDate.now(); 
  
            // getting ThaiBuddhistChronology 
            // used in ThaiBuddhistDate 
            ThaiBuddhistChronology crono 
                = hidate.getChronology(); 
  
            // getting ThaiBuddhistDate for the 
            // given date and year field 
            // by using dateYearDay() method 
            ThaiBuddhistDate date 
                = crono.dateYearDay( 
                    ThaiBuddhistEra.BE, 
                    2018, 
                    24); 
  
            // display the result 
            System.out.println( 
                "ThaiBuddhistDate is:"
                + date); 
        } 
        catch (DateTimeException e) { 
            System.out.println( 
                "passed parameter can "
                + "not form a date"); 
            System.out.println( 
                "Exception thrown:" + e); 
        } 
    } 
}
输出:
ThaiBuddhistDate is:ThaiBuddhist BE 2018-01-24

范例2:

Java

// Java program to demonstrate 
// dateYearDay() method 
  
import java.util.*; 
import java.io.*; 
import java.time.*; 
import java.time.chrono.*; 
  
public class GFG { 
    public static void main(String[] argv) 
    { 
        try { 
            // creating and initializing 
            // ThaiBuddhistDate Object 
            ThaiBuddhistDate hidate 
                = ThaiBuddhistDate.now(); 
  
            // getting ThaiBuddhistChronology 
            // used in ThaiBuddhistDate 
            ThaiBuddhistChronology crono 
                = hidate.getChronology(); 
  
            // getting ThaiBuddhistDate for the 
            // given date and year field 
            // by using dateYearDay() method 
            ThaiBuddhistDate date 
                = crono.dateYearDay( 
                    ThaiBuddhistEra.BEFORE_BE, 
                    2018, 
                    24); 
  
            // display the result 
            System.out.println( 
                "ThaiBuddhistDate is:"
                + date); 
        } 
        catch (DateTimeException e) { 
            System.out.println( 
                "passed parameter can "
                + "not form a date"); 
            System.out.println( 
                "Exception thrown:" + e); 
        } 
    } 
}
输出:
ThaiBuddhistDate is:ThaiBuddhist BEFORE_BE 2018-01-24

参考: https://docs.oracle.com/javase/9/docs/api/java/time/chrono/ThaiBuddhistChronology.html#dateYearDay-java.time.chrono.Era-int-int-




相关用法


注:本文由纯净天空筛选整理自RohitPrasad3大神的英文原创作品 ThaiBuddhistChronology dateYearDay(Era, int, int) method in Java。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。