Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Date-Calendar Addintion in year fields of sql date in a java page
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Pramit Bhaumik
Addintion in year fields of sql date in a java page
1 Answer(s)      2 years and 7 months ago
Posted in : Date-Calendar


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


Advertisement
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
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
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
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
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
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
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.
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.      
SQl Date
SQL Date       The SQL Date is used when you are working with dates. This include... The Tutorial illustrate a Example from SQL Date. In this Tutorial, we
Mysql Date Add Year
Mysql Date Add Year       Mysql Date Add Year explains to add the year to the particular... 'Mysql Date Add Year'. To graspe this example, we use Add('2008-12-15',INTERVAL 1
Mysql Year of Date
Mysql Year of Date       Mysql Year of Date is used to return the current year of the table... (current_date) that return the current year of  the table. Current_Date
Mysql Date Get Year
Mysql Date Get Year       Mysql Date Get Year is the way of retrieving the current year. Understand with Example The Tutorial illustrate an example from 'Mysql Date Get
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
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
JDBC : Get year from Date
')"; rs = statement.executeQuery(sql); System.out.print("Year of given date...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
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 object... year to current date $dateOneYearAdded = strtotime(date("Y-m-d"
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
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
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
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.  
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. Here
Advertisements
 

 

 

DMCA.com