Hello,

I have an amazing thing in my code, when I take the date from input txt file, and i put it to an output txt file, there was not the same date, for example:
if in the input the date birth for person is:
29/07/1981

when I get the date birth for the same person it was :
Sat May 07 00:00:00 IST 1983


What's the reason of this ?

Thank you,

I guess that would really depend on how you read and then wrote that date, wouldn't it?

Comments
Elementary, my dear Watson

I read the line like this (from the main class):

if (command.equals("addRaceDrivertoTeam")){ 	
// This method attach Race Driver to Team
String driverLicenseNumber=input.next();
String nationality=input.next();
String constructorName=input.next();
			       
boolean isUpdated=sys.addRaceDrivertoTeam(driverLicenseNumber,nationality,constructorName,input.next()+" "+input.next(), df.parse(input.next()),input.nextInt(),input.nextInt(),input.nextInt());

and This is the addRaceDrivertoTeam method that in the sys class:

public boolean addRaceDrivertoTeam(String driverLicenseNumber,String nationality,String constructorName, String fullName, Date dateOfBirth, int worldChampionships, int totalScore, int highestRaceFinish)

and the line that the main read it is:
addRaceDrivertoTeam D44KL987 Spanish Renault Fernando Alonso 29/07/1981 2 560 21

Check the date format that you are using to parse the input date. It looks like the format is reading month/day/year instead of your desired input format of day/month/year.

Note that 29 = 5 + 24. 24 months is two years and 5th month is May... now look at the output date with that in mind.

Okay then, just to be stinker, what date pattern is this?

09/02/03

YY/MM/DD
YY/DD/MM
DD/MM/YY
MM/DD/YY

March 2, 2009?
Feb 3, 2009?
Feb 9, 2003?
Sep 2, 2003?

;)

But you're right, that will cut out a lot of them, just not all.

This article has been dead for over six months. Start a new discussion instead.