Write a program in java to change the month and date in a statement 15 August is the Republic Day. The change should be done by the user and not in the form of print statement.
Answers
thanx piyush , and what this cal date format, i need to store this in mysql – kiran Feb 5 '11 at 6:23
mysql data type for date is DATETIME. – kiran Feb 5 '11 at 6:25
is this correct date format that cal return , that i can use to store in mysql – kiran Feb 5 '11 at 6:31
1
The Java code to add a month to current date in the desired format would be as shown below. Now, it's upto you to convert this String to a date and insert in into MYSql database. Note, that you can change the date format in DateFormat constructor or later in the MYSQL query using STR_TO_DATE(str, format) function. DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); Calendar now = Calendar.getInstance(); now.add(Calendar.MONTH, 1); String dateString = formatter.format(now.getTime()); – Piyush Mattoo Feb 5 '11 at 7:00