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 ///