Addintion in year fields of sql date in a java page

Addintion in year fields of sql date in a java page

In my database i have a field StartDate and EndDate Now entering date from my jsp and fetching it in the servlet

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


              Date date = new Date(request.getParameter("date"));
              SimpleDateFormat simpleDateformat=new SimpleDateFormat("yyyy");
              System.out.println("Year: " + simpleDateformat.format(date));
             String k= simpleDateformat.format(date);
            }

But I have to add 4 with the year value and generate the date after 4 years of Starting Date and store it into the database

View Answers

March 31, 2012 at 1:12 PM

The given code is useful.

try{
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
 Date d=(Date)formatter.parse("30-03-2012");
 Calendar cal=Calendar.getInstance();
 cal.setTime(d);
cal.add(Calendar.YEAR, 4);  
String newdate = formatter.format(cal.getTime());
System.out.println(newdate);
     }
     catch(Exception e){}









Related Tutorials/Questions & Answers:
Addintion in year fields of sql date in a java page
Addintion in year fields of sql date in a java page  In my database...("Year: " + simpleDateformat.format(date)); String k= simpleDateformat.format(date); } But I have to add 4 with the year value
convert date month and year into word using java
convert date month and year Java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
Advertisements
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Java Date Month Format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Match Date format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Basic format for Date and Month  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Convert Date Month format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Convert Date Format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Date Format in Jave  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
Add year to Date without using Calendar in java
Add year to Date without using Calendar in java  how could i add a year to a date function without using calendar functions
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   import java.util.*; import java.text.
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   import java.util.*; import java.text.
Mysql Date Add Year
Mysql Date Add Year       Mysql Date Add Year explains to add the year to the particular... an example from 'Mysql Date Add Year'. To graspe this example, we use Add
Java get year from date
Java get year from date    †... showing the format of year. The method simpleDateformat.format(date) formats a Date into a date/time string and returns the year.  ADS_TO_REPLACE_1 †
SQl Date
SQL Date       The SQL Date is used when you are working with dates. This include..._TO_REPLACE_1 The Tutorial illustrate a Example from SQL Date
Mysql Year of Date
Mysql Year of Date       Mysql Year of Date is used to return the current year of the table... from 'Mysql Year of Date'. To understand and grasp the example we use
Mysql Date Get Year
Mysql Date Get Year       Mysql Date Get Year is the way of retrieving the current year... 'Mysql Date Get Year'. To understand and grasp this example, we use
JDBC : Get year from Date
for no date. You can write sql query as -  sql = "SELECT YEAR('2000-12-31...JDBC : Get year from Date In this section, you will learn how to get year from date. Get year from Date : In MySql you can get year from the given Date
Java date add year
Java date add year In this tutorial, you will learn how to add years to date. Here, we are going to add few years to current date and return the date of that day. For this, we have created a calendar instance and get a date
JSP:How to get year of system date - Date Calendar
Year: "+year ); } } For more Examples on Java visit to : http...JSP:How to get year of system date  Please tell me how to get year of system date; I am doing import java.util.*; Date d = new Date(); d.getYear
PHP Date add 1 year
Adding 1 year to a php date object is sometimes useful to solve some... program. <?php //Example to add 1 year to a date objectADS...;"; //Add one year to current date $dateOneYearAdded = strtotime(date("
Subtraction of a date from Sql and other from java.
Subtraction of a date from Sql and other from java.  I want to subtract a date that i retrieve from mysql database with the system date that i retrieve from java. I want the difference between the two date in the integer form
java [ cannot retrive date from sql ] why??
java [ cannot retrive date from sql ] why??   import..._date, d,m,y; public void date_mdt()throws ParseException{ String date...-yyyy"); Date da=sdf.parse(getdate); String format=sdf.format(da); try
SQL Date, SQL Date Examples
SQL Date       In this we are going to discuss about the SQL Date functions. SQL stands... will be able to use the SQL Date functions effectively in your program.ADS_TO_REPLACE_1
date problem in sql server - SQL
date problem in sql server  select count(*) from xxxx_tbl where emplid="+emplid+" and work_dt=#"+work_date+"#"; work_date is in string ,Backend is sql server 2000.i am getting the date problem when using in jsp page. †
date range in sql
date range in sql  How can I select a random date from a date range in SQL server
Select today's date sql
Select today's date sql   I wanted to show the data from database according to the current date. So, can anyone give me the select today's date sql query? Thanks!   select current date in mysql query select * from
SQL date query
SQL date query  how to get ( 15 march 2011) and (15/03/2011) output using SQL   Use the following queries to get the data from database in the given format. For (15 march 2011) format: SELECT DATE_FORMAT(dob, '%d %M
how to display(update) current date and month in select box on selecting the year.
how to display(update) current date and month in select box on selecting the year.  how to display(update) current date and month in select box on selecting the year
java leap year
java leap year  write a java program that takes an input as a keyboard inputs or command line argument, a year between 1800 and 2000 and then reports whether itis a leap year. Aleap year is an integer greater than 1584
SQL get start date and end date result
SQL get start date and end date result  how to get ( 15 march 2011) and (15/03/2011) output using SQL
Fields in java class
Fields in java class       In this section, we will explore the concept of the fields in the reference of object oriented programming techniques. There are two part of the field
SQL Between Date
SQL Between Date       The Tutorial help you to understand SQL Between Date. In this Tutorial... Create Table Stu_Table (Stu_Id varchar(2), Stu_Name varchar(15), Stu_Dob date
Java Leap Year Problem
Java Leap Year Problem  I need help with a writing a program in Java that creates a class Year that contains a data field that holds the number of months in a year and the number of days in a year. It should include a get method
SQL display date in between query
SQL display date in between query  how to get ( 15 march 2011) and (15/03/2011) output using SQL
Sql Date Conversion
Sql Date Conversion       The Tutorial illustrate an example from 'Sql Date Conversion... the Year from the date you specified. ADS_TO_REPLACE_1 Query
date in textbox on page load
date in textbox on page load   i want to insret the current date...() { var mydate = new Date(); var year = mydate.getFullYear... into textbox on page load. <html> <script> function addDate(){ date = new
Sql Date and Time Format
Sql Date and Time Format       The Tutorial illustrate an example from the 'Sql Date and Time...,Month,Year and time. SELECT DATE_FORMAT('2008-12-15 15:53:00','%W %e
SQL Date
SQL Date         The SQL Date is used when you are working with dates. This include... Understand with Example The Tutorial illustrate a Example from SQL Date
leap year logic - Java Beginners
leap year logic  hi frds.. can u give me logic for leap year..  Hi Friend, Please visit the following link: http://www.roseindia.net/java/beginners/Leapyear.shtml Thanks
fields
fields  hi.create a class named librarybook that contains fields to hold methods for setting and getting a librarybooks title,author, and page count
Determining If a Year is a Leap Year in Java
Determining If a Year is a Leap Year in Java       Leap Year: Leap Year is the year contains an extra day. In the leap year, February month contains 29 days since normally
Java Date conversion - Date Calendar
Java Date conversion  How do I convert 'Mon Mar 28 00:00:00 IST 1983' which is a java.util.Date or String to yyyy/MM/dd date format in sql
Java converts any given year to Roman Numeral
Java converts any given year to Roman Numeral  Write a program that converts any given year to Roman Numeral
help with JDateChooser to insert date into sql
help with JDateChooser to insert date into sql  TextField3 = new com.toedter.calendar.JDateChooser(); TextField3.setDateFormatString("MM-d-y‚?¶ private void buttonActionPerformed(java.awt.event.Act‚?¶ evt) { try{ DateFormat df
Java Increment Date. - Java Beginners
Java Increment Date.  Create a program called Date.java to perform error-checking on the initial values for instance: fields month, day and year... ); } // Time3 constructor: day, month and year supplied. public Date( int d, int m
convert yyyy-mm-dd hh mm ss to date in sql
-mm-dd hh mm ss to date in sql? Thanks   Hi, You should use following code in SQL DATE_FORMAT(STR_TO_DATE(my_date, "%Y/%m/%d %H:%i:%s.%f"), "%Y-%m-%d %H:%i:%s") Thanks   Hi, Check SQL tutorials to learn java SQL

Ads