Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

trouble with java dates.

Thread view: 
Dasher - 21 Oct 2006 11:08 GMT
hi.

I am having trouble with some logic to change a String enetered using
BufferedReader and InputStreamReader . in the dd/mm/yyyy format.

I would like to seperate it into an int day,int month and a String
year.

Please help me.
Andrew Thompson - 21 Oct 2006 11:28 GMT
....
> I am having trouble with some logic to change a String enetered using
> BufferedReader and InputStreamReader . in the dd/mm/yyyy format.
>
> I would like to seperate it into an int day,int month and a String
> year.

See DateFormat.parse(java.lang.String) or alternately
roll your own solution using String.split("/") (1.4+) or
String.indexOf("/") and Integer.parseInt(string).

> Please help me.

And I suggest you try not to sound so pathetic and
needy, in future.

Andrew T.
Hal Rosser - 22 Oct 2006 06:19 GMT
> hi.
>
[quoted text clipped - 3 lines]
> I would like to seperate it into an int day,int month and a String
> year.

The SimpleDateFormat class can parse a string directly from a String into a
date.
(Assume strDateIn is a String formatted M/d/y)
DateFormat df = new SimpleDateFormat("M/d/y");
Date dateIn = df.parse(strDateIn);
///////  OR you can split your string into an array and go thataway ///


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.