The moose likes Java in General and the fly likes Finding Timestamp pattern from a String Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Finding Timestamp pattern from a String" Watch "Finding Timestamp pattern from a String" New topic
Author

Finding Timestamp pattern from a String

Akshay Bondre
Greenhorn

Joined: Sep 04, 2008
Posts: 13
I want to convert a String into Timestamp, the pattern for which is unknown. Is there any API given by java which allows us to feed in the string and returns the possible patterns that could work with it? I understand that one could have some pre-defined patterns against which the String can be parsed and checked. But, since this is a timestamp, the number combinations of different dates and times will be quite a lot. So, was looking for an efficient way of figuring out the pattern of the String-Timestamp.
Mohamed Sanaulla
Bartender

Joined: Sep 08, 2007
Posts: 2694

Cross posted on stackoverflow. Please BeForthrightWhenCrossPostingToOtherSites


Mohamed Sanaulla | My Blog
Akshay Bondre
Greenhorn

Joined: Sep 04, 2008
Posts: 13
Mohamed Sanaulla wrote:Cross posted on stackoverflow. Please BeForthrightWhenCrossPostingToOtherSites


I wasn't aware of this. Apologies to people who do get offended by cross posting.
I do believe that different set of people visit different forums and hence my intent while cross posting was only to get a quick reply.

A topic regarding the same doubt has been created at the following link too :

http://stackoverflow.com/questions/9156712/finding-timestamp-pattern-from-a-string
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 774

unless there are some rules on the format, this is impossible.
as the date 2012-01-03 could mean 3rd january or the 1st March 2012.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 1610

Wendy Gibbons wrote:unless there are some rules on the format, this is impossible.
as the date 2012-01-03 could mean 3rd january or the 1st March 2012.

I have to admit, I've never seen yyyy-dd-mm but, thanks to the @#!£* Americans, we do have mm-dd-yyyy.

But I take your point .

Winston


More computing sins are committed in the name of efficiency (without necessarily achieving it)
than for any other single reason...including blind stupidity. — W.A. Wulf
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 774

Winston Gutkowski wrote:
Wendy Gibbons wrote:unless there are some rules on the format, this is impossible.
as the date 2012-01-03 could mean 3rd january or the 1st March 2012.

I have to admit, I've never seen yyyy-dd-mm but, thanks to the @#!£* Americans, we do have mm-dd-yyyy.

But I take your point .

Winston


fair point 01-03-2012
 
 
subject: Finding Timestamp pattern from a String
 
Threads others viewed
For moderator of this group
Core Patterns
most valuable Patterns?
Can we have a list of J2EE patterns:
is it necessary to know all pattern
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture