954,545 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

convertion any date format to dd/mm/yyyy format and write to a file

hi want to know how read date from a file and take the data into a 2D array and again convert it in 1D array and covert the data format like 15-02-2012 or 15 02 2012 or 15s02s2012 into 15/02/2012 format and write it to other file

syekimubeen
Newbie Poster
2 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

You can write a Date object by using the SimpleDateFormat class with a format specification that describes exactly how you want it formatted. See the Java API documentation for details.
Inputting "any date format" is a much bigger problem - is there any limit or system to the range of input formats there could be?

JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

i tried and i'm able to convert some data formats to the requered but i'm not able to convert all the date format like 02-02-2012 or 02$02$2012 like this...format

syekimubeen
Newbie Poster
2 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

Are you saying its dd?mm?yyyy ie 3 numbers separated by an arbitrary delimiter?
If so you can use the String split(aRegex) method to break a string into pieces, using a given regular expression to determine where to split - eg ifyou use the regex fpr "anything that's not 0-9" (ask a Regex expert) those strings will split into a 3 element array containing dd, mm and yyyy respectively.

JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: