Demo20211202

import java.text.ParseException;
import java.text.SimpleDateFormat;

/**
 * 日期回文数
 * 
 * 今天:2021-1202
 * 下次:2030-0302
 *
 * @author ZengWenfeng
 * @date 2021.12.02
 * @mobile 13805029595
 */
public class Demo20211202
{

	final static public int M_MIN = 1;
	final static public int M_MAX = 12;

	final static public int D_MIN = 1;
	final static public int D_MAX_1 = 28;
	final static public int D_MAX_2 = 29;
	final static public int D_MAX_3 = 30;
	final static public int D_MAX_4 = 31;

	public static void main(String[] args)
	{
		for (int year = 1998; year <= 2099; year++)
		{
			calc(year + "");

		}

	}

	public static void calc(String year)
	{
		StringBuilder sbYear = new StringBuilder(year);
		String year_temp = sbYear.reverse().toString();

		String mm = year_temp.substring(0, 2);
		String dd = year_temp.substring(2);
		String strDate = year + mm + dd;

		SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
		boolean isOk = true;
		try
		{
			format.setLenient(false);
			format.parse(strDate);
		}
		catch (ParseException e)
		{
			e.printStackTrace();
//			System.err.println(e.getMessage());
			isOk = false;
		}

		if (isOk)
		{
			System.out.println("回文数日期:" + strDate);
		}

	}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值