How to Store Date

How to Store Date

How to Validate date in JTextField ,How I can Store it in Aceess Databse,
and I want to set Last Date of Admission,if Last date of admission is equal to current date then i want display Today is Last date of Admission ,if Current Date is Over than Last Date then I want to Disable All Admission Entry Form Contents.
Plz Help Me Sir Its Urgent sir.
View Answers

April 8, 2010 at 4:16 PM

Hi Friend,

1)Insert Date

import java.sql.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.text.*;
class InsertDate extends JFrame{

InsertDate(){
JLabel l=new JLabel("Enter Date (dd/MM/yyyy):");
final JTextField text=new JTextField(15);
JButton b=new JButton("Insert");
JPanel p=new JPanel(new GridLayout(2,2));
p.add(l);
p.add(text);
p.add(b);
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
String date=text.getText();
if(isValidDate(date)){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:access");
PreparedStatement ps = con.prepareStatement("INSERT INTO InsertDate(ID,lastDate) VALUES(?,?)");
ps.setString(1,"8");
ps.setString(2,date);
ps.executeUpdate();
System.out.println("inserted");
}
catch(Exception e){
System.out.println(e);
}
}
}
});
add(p);
setVisible(true);
pack();
}
public boolean isValidDate(String inDate) {

if (inDate == null)
return false;
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
dateFormat.setLenient(false);
try {
dateFormat.parse(inDate.trim());
}
catch (ParseException pe) {
return false;
}
return true;
}

public static void main(String[] args){
InsertDate insert=new InsertDate();
}
}

2)Check Status

import java.sql.*;
import java.awt.*;
import java.util.*;
import javax.swing.*;
import java.text.*;
import java.awt.event.*;

class CheckStatus{
public static void main(String[] args) {
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:access");
Statement st = con.createStatement();
ResultSet rs=st.executeQuery("Select lastDate from InsertDate where id='8'");
String ld="";
if(rs.next()){
ld=rs.getString("lastDate");
}

String lastDate=ld.substring(0,10);
System.out.println(lastDate);
java.util.Date d = new java.util.Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String todayDate=sdf.format(d);
System.out.println(todayDate);
java.util.Date date1 = sdf.parse(lastDate);
java.util.Date date2 = sdf.parse(todayDate);
if(date1.equals(date2)){
JOptionPane.showMessageDialog(null,"Today is Last date of Admission ");
}
else if (date1.before(date2)){
JOptionPane.showMessageDialog(null,"Admission is Over");
}
}
catch(Exception e){
System.out.println(e);
}
}
}

Thanks









Related Tutorials/Questions & Answers:
How to Store Date - Java Beginners
How to Store Date  How to Validate date in JTextField ,How I can Store it in Aceess Databse, and I want to set Last Date of Admission,if Last date of admission is equal to current date then i want display Today is Last date
To store date - JSP-Servlet
the method. And send the actual query to store the date also. With lots of thankzs.....   Hi friend, Code to store date in database...To store date  Hai friends, I want the format to store
Advertisements
Jsp Code to store date in database - JSP-Servlet
Jsp Code to store date in database   Hi, Can u give me jsp code to store current date in to database. Thanks Prakash
store current system date in to database - Development process
store current system date in to database  Hi,this is my code . here iwant to store current system date in to database and want to store subdept..."].elements["combo2"].options.length=0; for (var i=0;i<% java.util.Date date
How to store image into database
How to store image into database  Hi, all I want to store image into database using Java. Can anyone help me that how can i store image into database... through the following link How To Store Image Into MySQL Using Java
How to store an image in database
How to store an image in database  Hi........... How to store an image in postgresql using a query. I mean tell me the way to store an image using datatype. I am using the datatype bytea but tell me how to insert the image
how to write store procedure in sql
how to write store procedure in sql  How to write a store procedure in SQL Server
how to add date and change date in java - netbeans
how to add date and change date in java - netbeans  I need to code use to increase date How to get date after 30 days using netbeans
How to compare date in Java?
How to compare date in Java?  Hi, How to compare date in Java? Thanks   Hi, Check this example Date Comparison. Thanks
how to store,retrieve,modify the data
how to store,retrieve,modify the data  hello sir ,how to store,retrieve,modify the data using the swing please help me
How to store url path?
How to store url path?  Image is stored in physical directory like this String file = "C:/xampp/htdocs/jobqueen/" + username + createTimeStampStr() + ".PNG"; this physical directory is working fine but I want store in url
How to display date in JSP?
How to display date in JSP?  How to create a simple JSP program which displays date on the page? Thanks
how to get current date without system date
how to get current date without system date  is there any possiblity to get current date instead of system date in Java, as i dont want to change date in program and if i change date in OS automatically change in program also
How to Convert String to Date?
How to Convert String to Date?  Hi, I am new in Java and learning the Date manipulation in Java. I have to write a program in Java which converts... have to convert it to Date object. Tell me How to Convert String to Date? Thanks
How to display current date in textbox - Date Calendar
How to display current date in textbox  Hi guys, I'm really need your... Date(); var month = currentTime.getMonth() + 1; var day...(); document.forms[0].date_stamp.value = day + "-" + month + "-" + year
How to display date in JSP?
How to display date in JSP?  How to create a simple JSP program which displays date on the page? Thanks   Hi, You should import...; Then use the following code to print the current date: <%= new java.util.Date
How to store url path in file ?
How to store url path in file ?  Hi, How to store url path in file ? this my program public class Image implements Runnable..."; This is store phiscal directory but i want store url path like
how can we store the encrypted passwaord in swings?
how can we store the encrypted passwaord in swings?   how can we store the encrypted passwaord in swings
How to Store Image using JSF
How to Store Image using JSF  Hi How to upload images in db. using jsf. For jsf photo uploading .. I used this one code for upload image.. But this code haven't option to upload any images . i want to store image in db
how to store jtable value in multidimensional array?
how to store jtable value in multidimensional array?   i want to store the value of jtable in multidimensional array,with type double. how to store jtable value in multidimensional array
how to store jtable value in multidimensional array?
how to store jtable value in multidimensional array?   i want to store the value of jtable in multidimensional array,with type double. how to store jtable value in multidimensional array
how to store and then immediately retrieve when store the image into database?
how to store and then immediately retrieve when store the image into database?  how to store and then immediately retrieve when store the image into database?   Here is a jsp code that insert and retrieve image from
how to convert yyyyMMdd to date in python
how to convert yyyyMMdd to date in python  Hi, I have a date string 20221231 and I want to convert it to the date in Python. how to convert... is the similar example: How to get yesterday date in Python? Thanks
how to convert yyyyMMdd to date in python
how to convert yyyyMMdd to date in python  Hi, I have a date string 20221231 and I want to convert it to the date in Python. how to convert... is the similar example: How to get yesterday date in Python? Thanks
How to get the current date in Java?
How to get the current date in Java?  Hi, I am new to Java and trying to write a program to get the current date. How to get the current date in Java? Thanks   Hi, Check the tutorial: Java program to get current date
how to store dynamic array in hidden field in javascript?
how to store dynamic array in hidden field in javascript?  I have... to store it in a hidden field for passing it to the jsp page. so any one help me in how to store it in hidden field
How to capture video and then how to store it in mobile memory
How to capture video and then how to store it in mobile memory  Hello there, I'm developing a mobile application where i'm capturing video from... to store it in mobile memory. so plz tel me ow to do it. if you give example code i
How to calculate Date Difference in Java?
How to calculate Date Difference in Java?  Hi, I have two dates variable. How to calculate Date Difference in Java? Thanks   Hi, You can use the Calendar class for calculating the date difference in Java. Get data
date
date   how to insert date in database? i need coding
How to get max date in Hibernate?
How to get max date in Hibernate?  Hi, Tell the code to get the max date in Hibernate? Thanks   Hi, You can use the projection in Hibernate for getting the max date. Here is example code: Projections.max("addmision
How to use Date Picker iPhone
How to use Date Picker iPhone  Hi, I am beginner in mobile Application platform. I want to develop a small application in iphone platform to Show current date and display alert view message. So, how to define the date picker
store
store  i want to store data in (.dat) file format using swing and perform operation on that insertion,deletion and update
How to store JComboBox item into database
How to store JComboBox item into database   import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; import javax.swing.DefaultComboBoxModel; import javax.swing.JComboBox; import
how to find the given date is sunday
how to find the given date is sunday  how to find the given date... main(String[] args){ Date date= (new GregorianCalendar(2010..."); String day=f.format(date); if(day.equals("Sunday")){ System.out.println
store
store  hi i want store some information in my program and use them in other method. what shoud i do
How to convert date to string in Java?
How to convert date to string in Java?  Hello developers, I have java.util.Date object and it has to be converted to date format. How to convert date to string in Java? Thanks   Hi, To convert java.util.Date object
How to retrieve the ISO Date in PHP?
How to retrieve the ISO Date in PHP?  Hi, I am a beginner in PHP programming language. I have a query how to retrieve the ISO Date in PHP Language. Can any one suggest any reference for this. Thanks
date
date  how to store in database (oracle 10 g) using JDBC and servlets... database table name birthday (DOB date); dob with DATE data type in database while...=d.getTime(); java.sql.Date date = new java.sql.Date(t); try
How to convert date to time in PHP?
How to convert date to time in PHP?  Hi, programmer. The PHP programming language has several useful functions for getting and manipulating the date..., but as a readable date and time, it leaves much to be desired. Luckily, the PHP
How to store and retrieve image from database in JSP?
How to store and retrieve image from database in JSP?  Hi, In one of my application I have to store and then display the image in JSP. How to store and retrieve image from database in JSP? Thanks   HI, You can use
date
date  can u tell me how to calculate difference between a user provided date and the system date in java
date
date  can u tell me how to calculate difference between a user provided date and the system date in java
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
How to build calander - Date Calendar
How to build calander  My requirement is When user is registering he should enter his DOB just by selecting the date month and year for that i should provid him a calender right side of that feild how to do it please its
how to store data in XML file - JSP-Servlet
how to store data in XML file  hi i have to store the data for example user id and password in a xml file the input userid and password will be coming from jsp middle ware servlet how to do that?   Hi friend
how to store/retrieve doc file - Java Beginners
how to store/retrieve doc file  i want to wirte a code that stores/ retrieves .doc files to the mysql database using jsp pages... can anyone help me with the code?  Use this stuff inside your jsp page for store file
how to get date format in string from date object containing real date in java
how to get date format in string from date object containing real date in java  i want to get data string format from date object where date object containing real date. date frequently vary in from of only month & year

Ads