File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting string to specific date format

 
Thanuja Vishwanath
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

I have this requirement where i will get the date and time as string. Everytime this date and time string will vary in format ie.dd-MMM-yy format or dd/MMM/yy or MMM/dd/yy etc.

Now my problem is i want to parst this string to particular date format which iam not able to do as the original date string format differs for each case.

Iam able to convert the given string to date in specific format as below if i know the original date string format . But how do i do this if iam not aware of the original string format.



 
Paul Clapham
Sheriff
Pie
Posts: 20203
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanuja Vishwanath wrote:I am able to convert the given string to date in specific format as below if i know the original date string format . But how do i do this if i am not aware of the original string format.


It depends on what the possible list of unknown formats will be. For example if you were given "02-12-11" without being told the format, would that be February 12, 2011? Or would it be 02 December, 2011? Or perhaps 2002 December 11?

However if you have a list of possible formats which don't have any ambiguities like the example above, then just try them all until you find one which doesn't throw an exception.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic