Tyme4j Calendar Utility Library

repository·master·Indexed 42 days ago

https://github.com/6tail/tyme4j

A Java calendar utility library providing support for multiple calendar systems, including Gregorian, Lunar, Tibetan (Rab Byung), Hijri, zodiacs, sexagenary cycles, solar terms, lunar phases, and statutory holidays. Version 1.5.1 utilizes the SolarDay class as the primary entry point for date conversions.

Tokens
491
Snippets
2
Records
3
Agent score
4%

What's inside Tyme4j

  1. Install tyme4j via Maven

    master

    To use tyme4j in your Java project, add the following dependency to your pom.xml file.

    <dependency>
      <groupId>cn.6tail</groupId>
      <artifactId>tyme4j</artifactId>
      <version>1.5.1</version>
    </dependency>
  2. Use SolarDay to access multiple calendar systems

    master

    The SolarDay class is the primary entry point for working with Gregorian (Solar) dates. You can create a SolarDay instance using fromYmd(year, month, day) and then retrieve corresponding dates in other calendar systems such as Lunar, Rab Byung (Tibetan), and Hijri (Islamic).

    import com.tyme.solar.SolarDay;
     
    public class Sample {
      public static void main(String[] args) {
        // Create a SolarDay (Gregorian) instance
        SolarDay solarDay = SolarDay.fromYmd(1986, 5, 29);
         
        // Prints the Gregorian date
        System.out.println(solarDay);
         
        // Prints the Lunar date (e.g., 农历丙寅年四月廿一)
        System.out.println(solarDay.getLunarDay());
    
        // Prints the Rab Byung date (e.g., 第十七饶迥火虎年四月廿一)
        System.out.println(solarDay.getRabByungDay());
    
        // Prints the Hijri date (e.g., 1406年赖买丹月20日)
        System.out.println(solarDay.getHijriDay());
      }
    }