public class ChineseDate extends Object
Constructor and Description |
---|
ChineseDate(Date date)
通过公历日期构造
|
ChineseDate(int chineseYear,
int chineseMonth,
int chineseDay)
构造方法传入日期
此方法自动判断闰月,如果chineseMonth为本年的闰月,则按照闰月计算 |
ChineseDate(int chineseYear,
int chineseMonth,
int chineseDay,
boolean isLeapMonth)
构造方法传入日期
通过isLeapMonth参数区分是否闰月,如五月是闰月,当isLeapMonth为 true 时,表示润五月,false 表示五月 |
ChineseDate(LocalDate localDate)
通过公历日期构造
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
String |
getChineseDay()
获得农历日
|
String |
getChineseMonth()
获得农历月份(中文,例如二月,十二月,或者润一月)
|
String |
getChineseMonth(boolean isTraditional)
获得农历月份(中文,例如二月,十二月,或者润一月)
|
String |
getChineseMonthName()
获得农历月称呼(中文,例如二月,腊月,或者润正月)
|
int |
getChineseYear()
获得农历年份
|
String |
getChineseZodiac()
获得年份生肖
|
String |
getCyclical()
获得年的天干地支
|
int |
getDay()
获取农历的日,从1开始计数
|
String |
getFestivals()
获得节日,闰月不计入节日中
|
Calendar |
getGregorianCalendar()
获取公历的Calendar
|
Date |
getGregorianDate()
获取公历的Date
|
int |
getGregorianDay()
获取公历的日
|
int |
getGregorianMonth()
获取公历的月,从0开始计数
|
int |
getGregorianMonthBase1()
获取公历的月,从1开始计数
|
int |
getGregorianYear()
获取公历的年
|
int |
getMonth()
获取农历的月,从1开始计数
此方法返回实际的月序号,如一月是闰月,则一月返回1,润一月返回2 |
String |
getTerm()
获得节气
|
int |
hashCode() |
boolean |
isLeapMonth()
当前农历月份是否为闰月
|
String |
toString() |
String |
toString(ChineseDateFormat format)
获取标准化农历日期
支持格式
ChineseDateFormat.GSS 干支纪年 数序纪月 数序纪日
ChineseDateFormat.XSS 生肖纪年 数序纪月 数序纪日
ChineseDateFormat.GXSS 干支生肖纪年 数序纪月(传统表示) 数序纪日日
ChineseDateFormat.GSG 干支纪年 数序纪月 干支纪日
ChineseDateFormat.GGG 干支纪年 干支纪月 干支纪日
ChineseDateFormat.MIX 农历年年首所在的公历年份 干支纪年 数序纪月 数序纪日
|
String |
toStringNormal()
转换为标准的日期格式来表示农历日期,例如2020-01-13
如果存在闰月,显示闰月月份,如润二月显示2 |
public ChineseDate(Date date)
date
- 公历日期public ChineseDate(LocalDate localDate)
localDate
- 公历日期public ChineseDate(int chineseYear, int chineseMonth, int chineseDay)
chineseYear
- 农历年chineseMonth
- 农历月,1表示一月(正月)chineseDay
- 农历日,1表示初一public ChineseDate(int chineseYear, int chineseMonth, int chineseDay, boolean isLeapMonth)
true
时,表示润五月,false
表示五月chineseYear
- 农历年chineseMonth
- 农历月,1表示一月(正月),如果isLeapMonth为true
,1表示润一月chineseDay
- 农历日,1表示初一isLeapMonth
- 当前月份是否闰月public int getChineseYear()
public int getGregorianYear()
public int getMonth()
public int getGregorianMonthBase1()
public int getGregorianMonth()
public boolean isLeapMonth()
public String getChineseMonth()
public String getChineseMonthName()
public String getChineseMonth(boolean isTraditional)
isTraditional
- 是否传统表示,例如一月传统表示为正月public int getDay()
public int getGregorianDay()
public String getChineseDay()
public Date getGregorianDate()
public Calendar getGregorianCalendar()
public String getFestivals()
public String getChineseZodiac()
public String getCyclical()
public String getTerm()
public String toStringNormal()
public String toString(ChineseDateFormat format)
ChineseDateFormat.GSS
干支纪年 数序纪月 数序纪日ChineseDateFormat.XSS
生肖纪年 数序纪月 数序纪日ChineseDateFormat.GXSS
干支生肖纪年 数序纪月(传统表示) 数序纪日日ChineseDateFormat.GSG
干支纪年 数序纪月 干支纪日ChineseDateFormat.GGG
干支纪年 干支纪月 干支纪日ChineseDateFormat.MIX
农历年年首所在的公历年份 干支纪年 数序纪月 数序纪日format
- 选择输出的标准格式Copyright © 2025. All rights reserved.