Re: how to validate the pattern of date format
Posted By:
Anonymous
Posted On:
Friday, February 5, 2010 05:08 PM
i am just created the validation of date with a program, you must read this.
/**
* @(#)Date.java
*
*
* @author abansari
* @version 1.00 2010/2/4
* Date Format: 12/01/10
*/
import java.util.*;
public class Date
{
public static void main (String[] args)
{
String[] Months = {"a","Jan","Feb","Mar","Apr","May","June","July","Aug","Sept",
"Oct","Nov","Dec"};
String myDate = "01/01/10";
int token, month,day;
int len = myDate.length();
String[] temp;
// check
temp = myDate.split("/");
month = Integer.parseInt(temp[1]);
// day = temp[0];
token = temp.length;
if(len<8 || len>8 || token!=3)
{
System.out.println ("Invalid Format:");
System.out.println ("DD//MM//YY");
}
// else
{
System.out.println (temp[0]+"st " + Months[month] + " " + temp[2]);
}
}
}