package com.eactive.eai.test;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class DatePatternTester {

	/**
	 * @param args
	 */
	
    public static String getString(String patern)
    {
        SimpleDateFormat formatter = new SimpleDateFormat(patern);
        String curDate = formatter.format(Calendar.getInstance().getTime());
        return curDate;
    }

	public static void main(String[] args) {
//		String pattern = args[0];
//		System.out.print( "[TEST결과]" + pattern + "-->" + getString(pattern) );
//		for ( int year = 1971; year < 3000; year++){
//			if ( LunarCalendar.toSolar(year+"0815").substring(4).equals("0908"))
//				System.out.println(LunarCalendar.toSolar(year+"0815"));
//		}
//		System.out.println(LunarCalendar.toLunar("19421205"));
//		System.out.println(LunarCalendar.toSolar("20121029"));
		boolean res = isRightDate("20130731");
		System.out.println("res-->" + res);

	}
//	private static boolean isDateValue(String srcValue) {
//		try { (new SimpleDateFormat( "yyyyMMdd")).parse(srcValue); } catch (Exception e) { e.printStackTrace();  return false; }
//		return true;
//	}
	private static boolean isRightDate(String date) {
        String sdate = null;
        sdate = date.substring(0,4) + "-" + date.substring(4,6) + "-" + date.substring(6);

        java.sql.Date dt = null;
        try {
            dt = java.sql.Date.valueOf(sdate);
        } catch (Exception e) {
            return false;
        }

        if ( dt.toString().equals(sdate) ) return true;
        else return false;
    }


}
