Wednesday, May 13, 2009

How INTEGER value into DATE data type

class TestDate
{
public static void main(String args[])
{
DateFormat myformat = new SimpleDateFormat("MM/dd/yyyy");
String da = myformat.format(new Date());
Date ed = new Date();

try {
Date sd = myformat.parse(da);
da = myformat.format(new Date());
Calendar cal = Calendar.getInstance();
cal.setTime(sd);
int num = 1;

cal.add(Calendar.DATE, num);
ed = cal.getTime();
System.out.println("the privious date is : " + myformat.format(ed));

} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}

1 comment:

  1. its nice coding in java ...........laukik u r rocking.....

    ReplyDelete