date format to be updated with current date time

date format to be updated with current date time

package LvFrm;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.JButton;


@SuppressWarnings("serial")
public class Check extends JFrame implements ActionListener,ItemListener
{  

    //class declaration

    JFrame frm;
    JLabel lbl1,lbl2,lbl3,lbl4,lbl5,lbl6,lbl7,lbl8,lbl9,lbl10,
    lbl11,lbl12,lbl13,lbl14,lbl15,lbl16,lbl17,lbl18,lbl19,lbl20;
    JTextField txf1,txf2,txf3,txf4,txf5,txf6,txf7,txf8,txf9,txf10;
    JPanel panel1,panel2,panel3,panel4;
    Font f1;
    JComboBox i1,j1,k1;
    JButton b1,b2;

    //for date month year entry

    String strD[]={"Day","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"};
    String strM[]={"Month","Jan","Feb","Mar","App","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
    String strY[]={"Year","2012"};
        Check()
    {
        //for font setting

        f1=new Font("",Font.BOLD,25);
        this.setLayout(null);

        //frame declaration

        JFrame frm=new JFrame("first project");
        frm.setSize(650,400);
        frm.setLayout(null);

        /*Icon i=new ImageIcon("file:\\C:\\Documents%20and%20Settings\\All%20Users\\Documents\\My%20Pictures\\Sample%20Pictures\\Sunset.jpg");
        //.setIcon(new ImageIcon("C://Documents and Settings//smart vision//Desktop"));

        JLabel image=new JLabel(i);
        image.setBounds(100,100,125,120);
        frm.add(image);
        */

        lbl1=new JLabel("JOB WORK CENTRAL");
        lbl1.setBounds(235,10,135,35);
        frm.add(lbl1);
        lbl2=new JLabel("Home Shop ");
        lbl2.setFont(f1);
        lbl2.setBounds(220,30,330,40);
        frm.add(lbl2);
        lbl3=new JLabel("Mfrs. of :Baby Tricycles,Jhula,Walker,Rides,Accessories,"); 

        lbl3.setBounds(130, 20, 450, 100);
        frm.add(lbl3);

        lbl4=new JLabel (" Corrugated Box,Rolls,Sheets & Packing Materials");
        lbl4.setBounds(150, 30, 450, 105);
        frm.add(lbl4);

        lbl5=new JLabel("B39/4,SITE-IV,SAHIBABAD INDUSTRIAL AREA,,GAZIABAD(U.P)201010");
        lbl5.setBounds(100, 40, 480, 145);
        frm.add(lbl5);

        lbl6=new JLabel("Job Work :All Kinds Of Powder Coating Items");
        lbl6.setBounds(160, 30, 465, 135);
        frm.add(lbl6);

        lbl7=new JLabel("TIN NO:09888807951");
        lbl7.setBounds(10,10,125,30);
        frm.add(lbl7);

        lbl8=new JLabel("Dated 3-7-2008");
        lbl8.setBounds(10,20,135,40);
        frm.add(lbl8);

        lbl9=new JLabel("Customer Mob No-");
        lbl9.setBounds(10,80,135,90);
        frm.add(lbl9);

        //m/s label & textfld

        lbl10=new JLabel("M/s.");
        lbl10.setBounds(35,105,135,110);
        frm.add(lbl10);

        txf1=new JTextField();
        txf1.setBounds(70, 150, 130, 25);
        frm.add(txf1);

        //address label & textfld

        lbl11=new JLabel("Address");
        lbl11.setBounds(10,150,135,110);
        frm.add(lbl11);


        txf2=new JTextField();
        txf2.setBounds(70, 190, 130, 30);
        frm.add(txf2);

        //book no label & textfld

        lbl12=new JLabel("Book NO");
        lbl12.setBounds(250,105,80,110);
        frm.add(lbl12);

        txf4=new JTextField();
        txf4.setBounds(300, 150, 32, 20);
        frm.add(txf4);
        //sr no label n textfield

        lbl13=new JLabel(" Sr No");
        lbl13.setBounds(330,105,40,110);
        frm.add(lbl13);

        txf5=new JTextField();
        txf5.setBounds(364, 150, 40, 20);
        frm.add(txf5);

        //transport label & textfld

        lbl16=new JLabel(" Transport");
        lbl16.setBounds(245,150,70,145);
        frm.add(lbl16);

        txf6=new JTextField();
        txf6.setBounds(315, 212, 80, 25);
        frm.add(txf6);

        //g.r no label & textfld

        lbl17=new JLabel(" G.R No.");
        lbl17.setBounds(430,150,70,145);
        frm.add(lbl17);

        txf7=new JTextField();
        txf7.setBounds(480, 212,100, 25);
        frm.add(txf7);

        //creating button & adding to Frame

        b1=new JButton("Add");
        b1.setBounds(220,270,70,20);
        frm.add(b1);
        b1.addActionListener(this);


        b2=new JButton("Print");
        b2.setBounds(300,270,80,20);
        frm.add(b2);

        //panel1 declaration

        panel1=new JPanel();
        panel1.setLayout(null);
        panel1.setBounds(5, 10, 600,130);
        Border b1= BorderFactory.createLineBorder(Color.darkGray);
        panel1.setBorder(b1);
        frm.add(panel1);

        //panel2 declaration

        panel2=new JPanel();
        panel2.setLayout(null);
        panel2.setBounds(5, 140, 600,100);
        Border b2= BorderFactory.createLineBorder(Color.darkGray);
        panel2.setBorder(b2);
        frm.add(panel2);

     /*for date entry & adding date into panel 2
       also addind panel into frame
        */

        lbl14=new JLabel("Date");
        lbl14.setBounds(400,10,30,20);
        frm.add(lbl14);
        panel2.add(lbl14);

        i1=new JComboBox(strD);
        i1.setBounds(430, 10, 50, 20);
        i1.addItemListener(this);
        frm.add(i1);
        panel2.add( i1);
        j1=new JComboBox(strM);
        j1.setBounds(480, 10, 60, 20);
        j1.addItemListener(this);
        frm.add(j1);
        panel2.add(j1);
        k1=new JComboBox(strY);
        k1.setBounds(540, 10, 60, 20);
        k1.addItemListener(this);
        frm.add(k1);
        panel2.add(k1);

        /*time of removal goods label & text field &
         * adding it to panel2
         */

        lbl15=new JLabel("Time Of Removal Of Goods");
        lbl15.setBounds(245,30,170,30);
        frm.add(lbl15);
        panel2.add(lbl15);

        txf3=new JTextField();
        txf3.setBounds(425, 35, 170, 25);
        frm.add(txf3);
        panel2.add(txf3);

    frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frm.setVisible(true);

    }

    //main 
    public static void main(String args[])
    {
        new Check();
        new bean();
        new Conn();

    }

    @Override
    public void itemStateChanged(ItemEvent arg0) {
        // TODO Auto-generated method stub

    }

    @Override
    public void actionPerformed(ActionEvent arg0) {
        // TODO Auto-generated method stub

    }

    }
View Answers

April 3, 2012 at 4:41 PM

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

public class GetDate{
    static String months[]={"Month","Jan","Feb","Mar","App","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
    static int getMonth(String month){
    for(int i = 0; i<12; i++) {
      if(month == months[i])
          return i;
    }
    return 0;
    }
public static void main(String args[]){
GetDate get=new GetDate();
}
public GetDate(){
JFrame f = new JFrame();
f.getContentPane().setLayout(null);
final JComboBox day=new JComboBox();
final JComboBox month=new JComboBox();
final JComboBox year=new JComboBox();
JButton button= new JButton("Submit");
day.addItem("Day");
year.addItem("Year");
for(int i=1;i<=31;i++){
day.addItem(i);
}
day.setBounds(10,10,10,10);
for(int j=0;j<months.length;j++){
month.addItem(months[j]);
}
for(int k=1980;k<=2012;k++){
year.addItem(k);
}
day.setBounds(50,50,60,20);
month.setBounds(120,50,80,20);
year.setBounds(210,50,60,20);
button.setBounds(50,80,100,20);
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
Object ob1=day.getSelectedItem();
Object ob2=month.getSelectedItem();
Object ob3=year.getSelectedItem();
int d=Integer.parseInt(ob1.toString());
String mon=ob2.toString();
int m=getMonth(mon);
int y=Integer.parseInt(ob3.toString());
Calendar cal = GregorianCalendar.getInstance();
cal.set(y, m-1, d);  
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
System.out.println(sdf.format(cal.getTime()));
}
});
f.add(day);
f.add(month);
f.add(year);
f.add(button);
f.setVisible(true);
f.setSize(300,200);
}
}

April 3, 2012 at 4:42 PM

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

public class GetDOB{
public static void main(String args[]){
GetDOB get=new GetDOB();
}
public GetDOB(){
JFrame f = new JFrame();
f.getContentPane().setLayout(null);
final JComboBox day=new JComboBox();
final JComboBox month=new JComboBox();
final JComboBox year=new JComboBox();
JButton button= new JButton("Submit");
for(int i=1;i<=31;i++){
day.addItem(i);
}
day.setBounds(10,10,10,10);
for(int j=1;j<=12;j++){
month.addItem(j);
}
for(int k=1900;k<=2010;k++){
year.addItem(k);
}
day.setBounds(50,50,40,20);
month.setBounds(100,50,40,20);
year.setBounds(150,50,60,20);
button.setBounds(50,80,100,20);
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
Object ob1=day.getSelectedItem();
Object ob2=month.getSelectedItem();
Object ob3=year.getSelectedItem();
int d=Integer.parseInt(ob1.toString());
int m=Integer.parseInt(ob2.toString());
int y=Integer.parseInt(ob3.toString());

try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root";, "root");
PreparedStatement pstmt = conn.prepareStatement("insert into d(myDate) values(?)");
java.sql.Date sqlDate = new java.sql.Date(y-1900,m-1,d);
pstmt.setDate(1, sqlDate);
pstmt.executeUpdate();
JOptionPane.showMessageDialog(null,"Date in inserted successfully");
}
catch(Exception ex){}
}
});
f.add(day);
f.add(month);
f.add(year);
f.add(button);
f.setVisible(true);
f.setSize(300,200);
}
}









Related Tutorials/Questions & Answers:
date format to be updated with current date time
date format to be updated with current date time  package LvFrm...; JButton b1,b2; //for date month year entry String strD[]={"Day","1...); /*for date entry & adding date into panel 2 also addind panel
updated with current date n time
updated with current date n time  package LvFrm; import...; //for date month year entry String strD[]={"Day","1","2","3","4","5...); panel2.setBorder(b2); frm.add(panel2); /*for date entry
Advertisements
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
date format updated
date format updated  package LvFrm; import java.awt.Color; import... panel1,panel2,panel3,panel4; Font f1; JComboBox i1,j1,k1; JButton b1,b2; //for date...); panel2.setBorder(b2); frm.add(panel2); /*for date entry & adding
javascript current date and time.
write new Date() it shows the current date in standard format with current day,date,time and GMT.You can have your own format...javascript current date and time.  How can we display current date
c# current date in yyyy-MM-dd format
c# current date in yyyy-MM-dd format  Hi, How to get the current date in the format like 2021-01-12? I have to get the date into Year-Month-Date format. In c# how to get current date in yyyy-mm-dd format
Sql Date and Time Format
Sql Date and Time Format     ...; is used to  format date and time.  SYNTAX:- DATE_FORMAT(date,format)ADS...,Month,Year and time. SELECT DATE_FORMAT('2008-12-15 15:53:00','%W %e
Get current Date and Time
Get current Date and Time In this section we will discuss about how to get current date and time in java. Java provide two classes, Date and calendar which will display the current date and time in java. SimpleDateFormat is used 
J2ME Current Date And Time
J2ME Current Date And Time     ... the current date and time on the screen. Like core Java J2ME too use the same  java.util package to show the current date as well as current time on the screen
Mysql Date Format Convert
and time. Now, we help you to convert the Mysql Date Format Conversion into other... ( ) Query that return you the current today date and time. now ( ) : The Query now ( ) return you the current date and time Query for finding current date
Iphone Show Current Date & Time
Iphone Show Current Date & Time In the previous examples, we have printed current date and time separately in iphone simulator. But in this example we are going to show you how to print both current date and current time in iphone
JDBC: Get current Date and Time Example
JDBC: Get current Date and Time Example In this section, you will learn how to get current Date and current time using JDBC API. Get current Date and Time... in the format 'YYYY-MM-DD' You can get current date by writing 
Mysql Date Format codes
'. In this example we let you know ,how to display the current date and time in the system. The now ( ) as Date is used to display the current date, month, year and time... the current week, day, month and year. mysql> select date_format(now(),'%W
How to convert current date to dd mm yyyy format in Java?
How to convert current date to dd mm yyyy format in Java?  Hi, How to convert current date to dd mm yyyy format in Java? In my program I have to display the current date in the dd-mm-yyyy format to user on the website. How
Date and Time Format Example
Date and Time Format Example       This Example shows you date and time format... method is used for format Date into date/time String. DateFormatExample.java
Mysql Date and Time
; Mysql Date and Time is used to return the current date and time... Mysql Date and Time. To grasp this example, we use  Current_Timestamp query that return the current date and time. CURRENT_TIMESTAMP:-This is used
How to format current date into yyyy-mm-dd in Java
How to format current date into yyyy-mm-dd in Java  Hi, I have... database.I am searching code formatting the current date into this format. I have to do this in Java Programming Language. How to format current date
How to convert current date to mm dd yyyy format in Java?
How to convert current date to mm dd yyyy format in Java?  Hi, How to convert current date to mm dd yyyy format in Java? Share me the program... for converting current date into MM-dd-yyyy format. Here is full code: package
Date format - Date Calendar
Date format  please convert dd-mmm-yy date format to gregorian calendar date format.  Hi friend, Code related your Problem: import...]); Calendar calendar = new GregorianCalendar(pdt); Date time = new Date
date format - Date Calendar
date format  how to convert dd-mmm-yyyy date format to gregorian calendar format in JSP please tell me the code  Hi friend, Code...="19-Sep-2008"; DateFormat format ; Date date ; format = new
Get Date and Time
current date and time in the user given format. To do all this we have first... whose time fields have been initialized with the current date and time. getTime() method returns current time of date type. Here is the video tutorial of "
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
How can we get second of the current time using date function?
How can we get second of the current time using date function?  How can we get second of the current time using date function
Mysql Date no Time
; Mysql Date no Time is used to find out the current date with no time... no Time' in Mysql . In this Example, the date(now( ) ) return you the current date  with no time. date(now( ) ) : The date(now( ))  return you the current
Mysql Date Format
Mysql Date Format       The different types of time data in MySQL :TIME, DATE TIME and TIMESTAMP. The Tutorial helps you to write the Date Format in SQL Query.  date_format
Iphone Current Date Application
Iphone Current Date Application  Hi, I am a beginner in the mobile web application segment. How can i develop Iphone Current Date Application. I need the online help guide or example about iphone current date format. Thanks
Date & Time
Date & Time  How to insert System Date & Time in MS-ACCESS using Java
Date & Time
Date & Time  How to insert System Date & Time in MS-ACCESS using Java
Mysql Date from Date
an example from 'DateTime in Mysql'. To grasp this example, we use date(current_trimestamp ( )) query that return you the current date  from date time as Date...; Mysql  Date from Date Time in Mysql return the Current 
Write an Applet which display current date and time on the web page??
Write an Applet which display current date and time on the web page??  Write an Applet which display current date and time on the web page??  Here is an applet code that display date and time. import java.applet.
Write an Applet which display current date and time on the web page??
Write an Applet which display current date and time on the web page??  Write an Applet which display current date and time on the web page?  Here is an applet code that display date and time. import java.applet.
Current date in php
Current date in php  How to show the current date in the HTML page using PHP Script
NSDateformatter format Date
NSDateFormatter in string format. Thanks.   For current Date in NSDate...; In objective c, we use NSDate to show the Current Date and Time... that represent other data types. For example to show the date in string format we'll
How to get the current date in Java?
. Thanks   Hi, To get the current date and time in Java you can use...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
php date format change
php date format change  How to change the date format in PHP
date_time_set
date_time_set date_time_set alias DateTime::setTime function resets the the current time of the DateTime object to a different time. It returns the modified date and time.  Syntax public DateTime DateTime::setTime ( int
JDBC : Current Date
, CURRENT_DATE() functions  return the current date in format 'YYYY-MM-DD... the current date and time as a value in 'YYYY-MM-DD HH:MM:SS' SYSDATE()  : It returns the current date and time as a value in 'YYYY-MM-DD HH:MM:SS
Simple Date Format Example
Following is a simple date format example made using Format class. We have uses a pattern of special characters to date and time format. In this example, SimpleDateFormat:class is used to format date into text and parse text into date
current date set
current date set  I need to set current date as default in a drop down list which has a label tag too in my jsp page.please somebody help me
current date in php
current date in php  PHP script to get current date.   Hi, You can use the following code to print the current in PHP:ADS_TO_REPLACE_1... the current date in a variable: <? $today = date("F j, Y, g:i a"); ?>
date_format()
date_format() date_format alias DateTime::format function returns date formatted according to given format. It returns formatted date on success otherwise False on failure. Description on date_format() PHP public string DateTime::format
php date format validation
php date format validation  How to validate the date field in specific format in PHP
select date in desired format
select date in desired format  how to select date from the database in DD/MM/YYYY format, because if i am trying select data from the database i am getting value in yyyy/mm/dd and time format like below "2012-05-07 00:00:00.0
Mysql Date Arithmetic
in current date and time. Understand with ExampleADS_TO_REPLACE_1 The Tutorial..., we  run the select now ( ) query that return you the current date and time... returns you the 5 minute before the current minute. For current date+time
get current date in java in yyyy mm dd hh mm ss format
to get the current date into string yyyy mm dd hh mm ss format. How to get current date in java in yyyy mm dd hh mm ss format in a Java program? Thanks  ... java.text.SimpleDateFormat; import java.util.Date; /* * Format current date
Date Format Example
Date Format Example       This example shows how to format Date using Format class. In this program we use a pattern of special characters to date and time format
Current Date and Time
Current Date and Time
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
getting current date without using system date - Date Calendar
getting current date without using system date  I want to get the current date but the Java code should not get System date as Current date. Pleae help me in getting current date without using system date. thanks in Advance

Ads