package com.maxus.smartscene.utils;
import android.text.TextUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
public class SceneCalendar {
//生肖年
private String animal;
//干支年
private String ganZhiYear;
//阴历年
private String lunarYear;
//阴历月
private String lunarMonth;
//阴历日
private String lunarDay;
//阳历节日
private String solarFestival;
//阴历节日
private String lunarFestival;
//节气
private String lunarTerm;
/**
* 获取查询日期的年份生肖
*
* @return
*/
public String getAnimal() {
return animal;
}
/**
* 获取查询日期年份的天干地支
*
* @return
*/
public String getGanZhiYear() {
return ganZhiYear;
}
/**
* 获取查询日期的农历年份
*
* @return
*/
public String getLunarYear() {
return lunarYear;
}
/**
* 获取查询日期的农历月份
*
* @return
*/
public String getLunarMonth() {
return lunarMonth;
}
/**
* 获取查询日期的农历日
*
* @return
*/
public String getLunarDay() {
return lunarDay;
}
/**
* 获取查询日期的公历节日(不是节日返回空)
*
* @return
*/
public String getSolarFestival() {
return solarFestival;
}
/**
* 获取查询日期的农历节日(不是节日返回空)
*
* @return
*/
public String getLunarFestival() {
return lunarFestival;
}
/**
* 获取查询日期的节气数据(不是节气返回空)
*
* @return
*/
public String getLunarTerm() {
return lunarTerm;
}
final static long[] lunarInfo = new long[]{
0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2,
0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977,
0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970,
0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950,
0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557,
0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5d0, 0x14573, 0x052d0, 0x0a9a8, 0x0e950, 0x06aa0,
0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0,
0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b5a0, 0x195a6,
0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570,
0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x055c0, 0x0ab60, 0x096d5, 0x092e0,
0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5,
0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930,
0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530,
0x05aa0, 0x076a3, 0x096d0, 0x04bd7, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45,
0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0
};
//阳历天数
final static int[] solarMonths = new int[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
//生肖
final static String[] animals = new String[]{"鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"};
//天干
final static String[] tGan = new String[]{"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"};
//地支
final static String[] dZhi = new String[]{"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"};
//二十四节气
final static String[] solarTerms = new String[]{"小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏",
"小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪", "冬至"};
//二十四节气日期偏移度
private static final double D = 0.2422;
//特殊年份节气日期偏移
private final static Map<Integer, Integer[]> INCREASE_OFFSETMAP = new HashMap<Integer, Integer[]>();//+1偏移
private final static Map<Integer, Integer[]> DECREASE_OFFSETMAP = new HashMap<Integer, Integer[]>();//-1偏移
static {
INCREASE_OFFSETMAP.put(0, new Integer[]{1982});//小寒
DECREASE_OFFSETMAP.put(0, new Integer[]{2019});//小寒
INCREASE_OFFSETMAP.put(1, new Integer[]{2082});//大寒
DECREASE_OFFSETMAP.put(3, new Integer[]{2026});//雨水
INCREASE_OFFSETMAP.put(5, new Integer[]{2084});//春分
INCREASE_OFFSETMAP.put(9, new Integer[]{2008});//小满
INCREASE_OFFSETMAP.put(10, new Integer[]{1902});//芒种
INCREASE_OFFSETMAP.put(11, new Integer[]{1928});//夏至
INCREASE_OFFSETMAP.put(12, new Integer[]{1925, 2016});//小暑
INCREASE_OFFSETMAP.put(13, new Integer[]{1922});//大暑
INCREASE_OFFSETMAP.put(14, new Integer[]{2002});//立秋
INCREASE_OFFSETMAP.put(16, new Integer[]{1927});//白露
INCREASE_OFFSETMAP.put(17, new Integer[]{1942});//秋分
INCREASE_OFFSETMAP.put(19, new Integer[]{2089});//霜降
INCREASE_OFFSETMAP.put(20, new Integer[]{2089});//立冬
INCREASE_OFFSETMAP.put(21, new Integer[]{1978});//小雪
INCREASE_OFFSETMAP.put(22, new Integer[]{1954});//大雪
DECREASE_OFFSETMAP.put(23, new Integer[]{1918, 2021});//冬至
}
//定义一个二维数组,第一维数组存储的是20世纪的节气C值,第二维数组存储的是21世纪的节气C值,0到23个,依次代表立春、雨水...大寒节气的C值
private static final double[][] CENTURY_ARRAY = {
{6.11, 20.84, 4.6295, 19.4599, 6.3826, 21.4155, 5.59, 20.888, 6.318, 21.86, 6.5, 22.2, 7.928, 23.65, 8.35, 23.95, 8.44, 23.822, 9.098, 24.218, 8.218, 23.08, 7.9, 22.6},
{5.4055, 20.12, 3.87, 18.73, 5.63, 20.646, 4.81, 20.1, 5.52, 21.04, 5.678, 21.37, 7.108, 22.83, 7.5, 23.13, 7.646, 23.042, 8.318, 23.438, 7.438, 22.36, 7.18, 21.94}
};
//农历月份
final static String lunarNumber[] = {"一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"};
//农历年
final static String[] lunarYears = new String[]{"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"};
final static String[] chineseTen = new String[]{"初", "十", "廿", "卅"};
//农历节日
final static String[] lunarHoliday = new String[]{"0101 正月初一","0102 正月初二","0103 正月初三","0104 正月初四","0105 正月初五","0106 正月初六","0107 正月初七","0108 正月初八","0109 正月初九","0110 正月初十","0111 正月十一","0112 正月十二","0113 正月十三","0114 正月十四", "0115 元宵节", "0202 龙头节", "0505 端午节", "0707 七夕节", "0715 中元节",
"0815 中秋节", "0909 重阳节", "1001 寒衣节", "1015 下元节", "1208 腊八节", "1223 小年"};
//公立节日
final static String[] solarHoliday = new String[]{"0101 元旦", "0214 情人节", "0308 妇女节", "0312 植树节", "0315 消费者权益日",
"0401 愚人节", "0422 地球日", "0423 读书日", "0501 劳动节", "0504 青年节", "0512 护士节", "0518 博物馆日", "0519 旅游日", "0601 儿童节",
"0701 建党节", "0801 建军节", "0910 教师节", "1001 国庆节", "1024 联合国日","1031 万圣节", "1204 宪法日", "1224 平安夜", "1225 圣诞节"}
评论0