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);
}
}
}
Demo20211202
最新推荐文章于 2024-10-02 10:07:45 发布