If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > JAVA > User to type in Birth Date and Hire Date

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-19-10, 09:09
Akinyemi Akinyemi is offline
Registered User
 
Join Date: Jul 2006
Posts: 24
User to type in Birth Date and Hire Date

Hi,
I have been trying to write a java code will request the user to type in his or her birth date, and hire Date but have not been able to. Please see what I am only able to do:
/**
*This program will show date as 13/07/1961.
*It is the user that should fill in the date on line?
*/
import java.util.Calendar;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;



public class DateDemo
{
public static void main(String[] args)
{
Scanner userInput = new Scanner(System.in);
String date = userInput.nextLine();
Calendar cal = Calendar.getInstance();
cal.set(2005, Calendar.JULY, 13); //year, month, date
Date birthDate = cal.getTime();

SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
String str = sdf.format(birthDate );
System.out.println(" A Special Date: " + str);
}
}


I should be very grateful if someone can help me perfect it. I have searched for the solution in all my books but couldn't find any relevant example.

Please help me.
Thank you.

Akinyemi
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On