java date
Hi,
Please observe the below code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
class LoginDemo{
JButton SUBMIT;
JFrame f;
JLabel label1,label2;
final JTextField text1;
final JPasswordField text2;
LoginDemo(){
f=new JFrame();
f.getContentPane().setLayout(null);
label1 = new JLabel();
label1.setText("UserName:");
label1.setBounds(400,50,100,20);
text1 = new JTextField(25);
text1.setBounds(500,50,100,20);
label2 = new JLabel();
label2.setText("Password:");
label2.setBounds(400,80,100,20);
text2 = new JPasswordField(25);
text2.setBounds(500,80,100,20);
SUBMIT=new JButton("Login");
SUBMIT.setBounds(500,110,100,20);
f.add(label1);
f.add(text1);
f.add(label2);
f.add(text2);
f.add(SUBMIT);
f.setSize(1024,768);
f.setVisible(true);
SUBMIT.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
String value1=text1.getText();
String value2=text2.getText();
String user1="";
String pass1="";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection con = DriverManager.getConnection("jdbc:odbc:msdesktop");
Statement st = con.createStatement();
ResultSet res = st.executeQuery("SELECT * FROM test where Empname='"+value1+"' and Emppassword='"+value2+"'");
while (res.next()) {
user1 = res.getString("Empname");
pass1 = res.getString("Emppassword");
}
if(!value1.equals(user1) && !value2.equals(pass1)) {
JOptionPane.showMessageDialog(null,"Incorrect login or password","Error",JOptionPane.ERROR_MESSAGE);
text1.setText("");
text2.setText("");
}
else if(value1.equals("")){
JOptionPane.showMessageDialog(null,"Please Enter Username");
}
else if(value2.equals("")){
JOptionPane.showMessageDialog(null,"Please Enter Password");
}
else{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:odbc:msdesktop");
PreparedStatement pstmt = conn.prepareStatement("insert into logininformation(username,logindate,logintime) values(?,?,?)");
pstmt.setString(1, value1);
java.sql.Date sqlDate = new java.sql.Date(new java.util.Date().getTime());
pstmt.setDate(2, sqlDate);
java.sql.Time sqlTime = new java.sql.Time(new java.util.Date().getTime());
pstmt.setTime(3,sqlTime);
/*java.sql.Timestamp sqlDate = new java.sql.Timestamp(new java.util.Date().getTime());
pstmt.setTimestamp(2, sqlDate);*/
pstmt.executeUpdate();
pstmt.close();
conn.close();
JOptionPane.showMessageDialog(null,"Login Successful");
}
catch(Exception ex){}
}
}
catch(Exception e){
System.out.println(e.getMessage());
}
}
});
}
public static void main(String arg[]) {
LoginDemo frame=new LoginDemo();
}
}
the o/p is properly coming .
when the proper user is "login" the name,date,time is automaticaaly inserted into the database .
My doubt is iam storeing system date and system time but i want to store i server time and server date.
pls help me.
View Answers
Related Tutorials/Questions & Answers:
Java DateJava Date Hi,
What is the API for
Date management in
Java? How use the
Java Date API for manipulating
date object in
Java?
Provide some... of API for working with
date and time objects in
Java. You can also use third
Advertisements
Mysql Date To Java Date
Mysql
Date To
Java Date
Mysql
Date To
Java Date retrieve the records from Mysql and display the
date
in
java.
Understand with ExampleADS_TO_REPLACE_1
The Tutorial illustrate
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
java - Date CalendarJava convert string to date I need an example in
Java to convert the string to
date. Convert string to
date formatimport... str_
date="04-04-2008"; DateFormat formatter ;
Date date Display Date - Java BeginnersDisplay Date Plz send me sample
java program that display day,
date... to display day,
date,year and current time.
import java.util.*;
class DateExample
{
public static void main(String[] args)
{
Date date = new
Date java format datejava format date Hi,
How can I format the
date in the following...)
{
Date date=new
Date();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
String formattedDate=sdf.format(
date date - Java Beginnersdate 1.Write a program to check input
date is valid or not using
java(value must be given by user) Hi Friend,
Try the following code... DateValidation{
public boolean isValidDate(String
date){
SimpleDateFormat sdf = new
Parsing date in JavaParsing
date in Java How can i parse the
date in
Java in a simple format..?
SimpleDateFormat parserSDF=new SimpleDateFormat("EEE MMM d HH:mm:ss zzz yyyy
datedate can u tell me how to calculate difference between a user provided
date and the system
date in
java datedate can u tell me how to calculate difference between a user provided
date and the system
date in
java datedate i want difference between the
date entered in a jtextfield and the system
date in
java java Date - Java Beginnersjava Date Dear sir I have an assignment, It is ..
"Develop
Date class in
java similar to the one available in java.util package.Use JavaDoc...,
Try the following code:
public class
Date {
private final int month
Java Date - Java BeginnersJava Date I have to find the previous
date's beginning time and end time in the long milliseconds format. for example today
date is '23rd April... main(String[] args) {
Date now = new
Date(); DateFormat df Hi friend
Date Java - Java BeginnersDate Java I'm using the eclipse software and I get an error for my...:
public class
Date {
private int month; // 1-12
private int day; // 1-31... for day.
public
Date( int theMonth, int theDay, int theYear ) {
if ( theMonth
java yesterday - Date Calendarjava yesterday And how to make
date format DD/MM/YYYY,thank's ... static void main(String args[]){
Date todaysDate = new java.util.Date... formattedDate = formatter.format(todaysDate);
System.out.println("Formatted
date ask java - Date Calendar but in
java i found too but i can't to join in another frame. And i want to ask how to subtract a
date, ex:i work since 2008/09/01 so i'am work until now 1 month 10... {
public static void main(String[] args) {
Date date = new
Date java yesterday - Date Calendarjava yesterday Afternoon,Yesterday i have a question that how to make
date sustract, the result is to make 1 month and 1 day like this, right. now how about 1 year and 1 month? And Can help me to using
Date Calender what
Date picker in Java SwingDate picker in
Java Swing Hello Sir,
Sir ,I am in need of Time Picker just like the
Date picker available in
java Swing. Kindly... link:
Java Date Time Picker Example
Hello Sir,
Thank
Java DateThe
Java Date class allows the developers to manipulate
date and time from
within the
Java program. The
Java Date class is very useful class and it is used... in
your program you will have to use the
Java Class to manipulate the
date Java String To DateJava String To
Date
In this section you will read about how to convert... be convert into
java.util.Date.
Java string to
date convert explains the conversion of
Java
string written into the specified format to a
Java date object
Getting Computer Date in javaGetting Computer
Date in java Hi , I want to get the PC
Date... but this..
String strDate = new
Date();
I get this server error, "The type
Date is ambiguous".
I've also tried
Date date = new
Date(); ... but it get's the same error
date problem - Java Beginnersdate problem how to extract day,month,year hours ,second from a string
date.
Examples:
String dat ="200912202934" from this string extract month ,year,
date,hours,minute
Please help me.
Thanks in advance
Sushil
java - Date Calendarjava Using
java how can i change the
date format of the system from mm/dd/yy to dd/mm/yy. The code which i wrote is changing the format only on the console and not on the system's control panel.Can you suggest me anything
java again - Date Calendarjava again I can't combine your source code yesterday, can you help... :
Date now : jtextfield1 //jTexfield1=
date now
//we enter ,then result in jTextfield2
Date work : jtextfield2
This my Source
date and time in awt(java)date and time in awt(
java) sir,
do you have an example of
date in awt
java which can be view over a textfield.
Display time in JTextField
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
public
java date - Java Beginnersjava date
Hi,
Please observe the below code:
import... is "login" the name,
date,time is automaticaaly inserted into the database .
My doubt is iam storeing system
date and system time but i want to store i server
date problem - Java Beginnersdate problem how to extract day,month,year hours ,second from a string
date.
Examples:
String dat ="200912202934" from this string extract month ,year,
date,hours,minute
Please help me.
Thanks in advance
Sushil
date format - Java Beginnersdate format how to 45day in dd-mmm-yyyy
date format. Hi...-yyyy", Locale.US);
Date d = sdf.parse(timestamp);
Calendar cal...";
System.out.println("
Date is : " + timestampToParse);
Calendar cal = parseTimestamp
date date how to insert
date in database? i need coding
date format - Java Beginnersdate format How to convert yyyy-mm-dd to dd-mmm-yyyy Hi... void main(String args[]) throws Exception{
Date todaysDate = new java.util.Date...-dd
date is ==>"+formattedDate);
Date date1 = formatter.parse
Day for the given Date in JavaDay for the given
Date in Java How can i get the day for the user...);
System.out.println("Enter
date(1-31):");
int dd=input.nextInt...;
System.out.println("Enter year: ");
int year=input.nextInt();
Date date= (new
Date - Java BeginnersDate how to add 45day in dd-mmm-yyyy
date format but not current... {
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy", Locale.US);
Date d...{
String timestampToParse = "02-Dec-2008";
System.out.println("
Date continue java - Date Calendarcontinue java and how to subtract
date(day month year) form jframe...();
}
}
});
}
public void getDiffer(String dt1, String dt2) throws ParseException{
Date date1;// = new
Date();
Calendar calendar = Calendar.getInstance
Java Date ClassJava Date Class Hi Friend, I need to have a code to get the days between specific dates.
Such if I enter 19 September 2011 to 21 September 2011, the days would be saturday, sunday and monday, the code I gave simply get one day
continue java - Date Calendarcontinue java How to make a subtract
date from jframe like jtexfield, data can input into jtextfied ? and how to get year, yesterday a have a question about how to substract dd mm yyyy can in this subtract have a year.thank
datedate how to insert
date using html through the combobox
datedate how to insert
date using html through the combobox
datedate how to insert
date using html through the combobox
datedate how to insert
date using html through the combobox
java date selector ..java date selector .. hey,,,, i am creating my
java project...for that i implementing a car renting system and i had used combo boxes to get Ranting start day inputs..3 combo(sy,sm,sd) yyyy ,mm,dd and for returning day i need
How to get the current date in Java?How to get the current
date in
Java? Hi,
I am new to
Java... in
Java?
Thanks
Hi,
Check the tutorial:
Java program to get current
date.
Thanks
Hi,
To get the current
date and time in
Java you can use
Java Coding - Date CalendarJava Coding Write a program that prompts the user to enter the year and first day of the year and displays the calendar for the year on the console. For example,if the user entered the year 2005, and 6 for Saturday, January
Java Program - Date CalendarJava Program A
java program that display calendar. Hi Friend,
Try the following code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.
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 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 {
System.out.println(
date);
Class.forName("oracle.jdbc.OracleDriver");
con