Home J2me Date Field Midlet Example
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Date Field Midlet Example

Advertisement
This example illustrates how to insert date field in your form.

Date Field MIDlet Example

     

This example illustrates how to insert date field in your form. We are using here two fields DateField (datein and dateout) and initialize a final static variable DATE which is 0. We are taking both DateField variable in to the constructor (DateFieldExample). When application will run, first of all the startApp() method will be called and it will display the form with datein and dateout field. For the specific date we are using here java.util.Date class and java.util.TimeZone class is used to show the format of date like in figure Tue, 30 Sep, 2008

Application display as follows:

When <date> is selected, a new window will open with a calendar as given below.

and you can select your choice of date, month and year which will appear on the form as follows. 

 

The source code of the DateFieldExample.java is as follows:  

import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import java.util.Date;
import java.util.TimeZone;

public class DateFieldExample extends MIDlet{
  private Form form;
  private Display display;
  private DateField datein, dateout;  
  private static final int DATE = 0;

  public DateFieldExample(){
  datein = new DateField("Date In:", DateField.DATE, TimeZone.getTimeZone("GMT"));
  dateout = new DateField("Date Out:", DateField.DATE, TimeZone.getTimeZone("GMT"));
  }

  public void startApp(){
  display = Display.getDisplay(this);
  Form form = new Form("Date Field");
  form.append(datein);
  form.append(dateout);
  display.setCurrent(form);
  }

  public void pauseApp(){
  
  }

  public void destroyApp(boolean destroy){
  notifyDestroyed();
  }
}
<> 

Download Source Code

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 3, 2008

Related Tutorials

Ask Questions?    Discuss: Date Field Midlet Example   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
mayur
May 31, 2012
thks

thanks
DMCA.com