-1

hi im parsing a csv file with date(custom format), i have to parse the date given in anyformat(mm-dd-yyyy, yyyy/mm/dd , mmm dd yyyy) to a standard format dd/mm/yyyy.

The question is how can we find the format in which the date is given?

is there anyway to do it?

ps: i thinking of asking for the dateformat in the csv.

dinodd88
  • 17
  • 8

1 Answers1

2

In your case, the string should contain just one of either "-" or "/" or " ", so you can dispatch based on that.

Thilo
  • 257,207
  • 101
  • 511
  • 656
  • @Thila , i dont know the format given in csv , it can be of anyformat available. – dinodd88 Jun 27 '12 at 07:06
  • 1
    Be careful on using a list of patterns. It could mean different than what you will interpret. ex. 1/2/3 - It's going to be pure luck and no logic with this approach. – panzerschreck Jun 27 '12 at 07:10
  • Any format available? That's not going to work well. For starters, it's ambiguous. – Thilo Jun 27 '12 at 08:09