Home Answers Viewqa Java-Beginners How to Store Date

 
 


shweta
How to Store Date
1 Answer(s)      3 years and a month ago
Posted in : Java Beginners

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 Pages:
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
date
date   how to insert date in database? i need coding
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
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 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 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
store values of drop down list box in database
store values of drop down list box in database  how to store values of drop down list box in oracle database in jsp?I have information inserting form where i have date of birth as drop down list box
DATE
of calcultion starts My question is how to find the date of Thursday This cycle...DATE  I have the following as my known parameter Effective Date... the date of all the thursdays of the given year. import java.util.*; import
date
date  actually i need to print morning , evening from config file .tell me the idea .how do i get coding
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
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 write store procedure in sql
how to write store procedure in sql  How to write a store procedure in SQL Server
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 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 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 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 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 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
iPad App to store data
iPad App to store data  Hi, How to add data support iPad application? Thanks
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
image store and get it back
store the image in table but at time of reading it back it never shows me the image and how to convert the image file into binary format.... so that i can store...image store and get it back  store the image in the oracle using blob
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
Store Variable in Java
Store Variable in Java  How to store Variables in Java?   public class DoubleTest { public static void main(String[] args) { double aDouble = 5.76; // Declare and initialize aDouble System.out.println
Java Xml Data Store
phone number, nature and date of the enquiry, and the name of the salesperson... enquiries sorted by date (ascending or descending) depending if they have be followed up and/or purchased. You will need to store the data in a local binary
About Store Procedure
About Store Procedure  Create Procedure CMTSPCasesByWorkstream...((Cast(dateadd(day,-7,cast(getdate() as Date)) as varchar) + ' 23:59:59') as Datetime) -- 'yyyy-mm-dd hh:mm:ss' Declare @startdate datetime = @paramstart_date
Android mobile store
Android mobile store  Hi, How to create Android mobile store application? Is there any free code that can be used for creating the applications? I... it from Android market place. How it can be done? Thanks
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
store
store  i want to store data in (.dat) file format using swing and perform operation on that insertion,deletion and update
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
store
store  hi i want store some information in my program and use them in other method. what shoud i do
date format - Date Calendar
date format  how to convert dd-mmm-yyyy date format to gregorian... to convert date to calender. import java.util.*; import java.text.*; public...="19-Sep-2008"; DateFormat format ; Date date ; format = new
servlet program for data store in oracle?
servlet program for data store in oracle?  how to store data in oracle through servlet program
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 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
Insert current date into MYSQL database
Insert current date into MYSQL database In this tutorial, you will learn how... to store dates in the database system like DATE, TIMESTAMP, DATETIME and YEAR.... If you will enter a date in another format, it wouldn't store the date you
how to store a dynamic values - JSP-Servlet
how to store a dynamic values  Dear sir, i have a ArrayList in that i have stored a values from a excel sheet specified column values and i have one string that is as follows Dear ~2 , Your cl is ~3 ,el is ~4
how to store and retrieve image from database
how to store and retrieve image from database  how to store and retrieve images into database(oracle) and how to retrive images from database using jsp   Here is a jsp code that insert and retrieve image from mysql
Date Formay - Date Calendar
Date Formay  Sir, How to comapare two different date format in java.  Hi friend, Code to compare two different date import...)) System.out.print("Current date(" + new SimpleDateFormat("dd/MM/yyyy"). format
convert current date into date format
convert current date into date format  How to get current date and convert into date format in Java or PHP
store and retrive image from the database
store and retrive image from the database  please provide me with the code and the explanation of what each line does for the below query. -how to store and retreive images from sql database using sql commands -how to store
Date format - Date Calendar
Date format  Hi All, I am getting a date from database as a format 2010-15-07.I need to change it to 07/15/2010 and display it on my date field.Every time i need to check the format of the date field and make sure the correct
Date limit on Dojo Date picker - Date Calendar
beyond or before date limit from dojo date picker itself. It means how to disable...Date limit on Dojo Date picker  Hi all, I am using dojo for date picker in my project. When user click on date text box, date picker will pop up

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.