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

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 5 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
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 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
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 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
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.  
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 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
date range in sql
date range in sql  How can I select a random date from a date range in SQL server
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
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
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
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
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 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
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
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
SQL Between Date
SQL Between Date       The Tutorial help you to understand SQL Between Date. In this Tutorial..._Table (Stu_Id varchar(2), Stu_Name varchar(15), Stu_Dob date); Insert Data
Mandatory Fields Validation - Java Beginners
Mandatory Fields Validation  In my login servlet, i have fields... javascript. Call a javascript function before submit the page. Example... this through javascript. Call a javascript function before submit the page. Example
Sql Date Conversion
Sql Date Conversion       The Tutorial illustrate an example from 'Sql Date Conversion... the Year from the date you specified. Query:- SELECT DATE
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
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
SQL Date
SQL Date         The SQL Date is used when you are working with dates. This include... with Example The Tutorial illustrate a Example from SQL Date. In this Tutorial
Sql Date and Time Format
Sql Date and Time Format       The Tutorial illustrate an example from the 'Sql Date and Time... return you the format date in the order of Week,Day,Month,Year and time
Retrieve all the students in the same year(Java ArrayList)?
Retrieve all the students in the same year(Java ArrayList)?  FoundStudents.jsp year- parameter I receive from a form search- is an object of type Student, with ID, name, year <% Student search = null; ArrayList<Student>
Fields and Methods in Java
In this section we are discussing about Fields and Methods in Java. Fields or variables of class and Methods of a class are important while writing the Java... easily and quickly. The video explains in detail the use of fields in Java
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
 

 

 

DMCA.com