trouble with java dates.

D

Dasher

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.
 
A

Andrew Thompson

Dasher wrote:
.....
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.
 
H

Hal Rosser

Dasher said:
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.


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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,268
Messages
2,571,094
Members
48,773
Latest member
Kaybee

Latest Threads

Top