package quote_price;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.shiro.SecurityUtils;

import lingtao.net.bean.SysUser;
import lingtao.net.util.LunarCalendarUtil;

public class LunarToSolarTest {

	public static void main(String[] args) throws ParseException {
		// 将公历日期转换为农历日期
		int[] solarToLunar = LunarCalendarUtil.solarToLunar(2021, 7, 8);
		String LunarDate = "";
		for (int i = 0; i < 3; i++) {
			LunarDate += solarToLunar[i] + "-";
		}
		// 将农历日期转换为公历日期
		int[] lunarToSolar = LunarCalendarUtil.lunarToSolar(2021, 5, 29, true);
		String SolarDate = "";
		for (int i = 0; i < 3; i++) {
			SolarDate += lunarToSolar[i] + "-";
		}
		LunarDate = LunarDate.substring(0, LunarDate.length() - 1);
		SolarDate = SolarDate.substring(0, SolarDate.length() - 1);

		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		Date d1 = sdf.parse(SolarDate);
		Date d2 = sdf.parse(LunarDate);

		long daysBetween = (long) ((new Date().getTime() - d1.getTime()) / (60 * 60 * 24 * 1000));
		System.out.println(LunarDate + " 与 " + SolarDate + "间隔 " + daysBetween + " 天");
		SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
		System.out.println(user.getRealname());
	}
}
