aspose file tools*
The moose likes Java in General and the fly likes Parsing locale specific Datetime String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Parsing locale specific Datetime String" Watch "Parsing locale specific Datetime String" New topic
Author

Parsing locale specific Datetime String

Jammie Jamloki
Greenhorn

Joined: Nov 29, 2006
Posts: 1
How can I parse locale specific date-time.

for example

"16 déc. 2012 08:55:55" -- please note :"déc"

Is there any generic way ?
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3169
    
  10
I haven't tried this but from a look at the DateFormat javadoc I would think using the setCalendar method to apply a Calendar with the required Locale might be worth trying.

Joanne
Ishan Pandya
Ranch Hand

Joined: Feb 06, 2012
Posts: 213


try getDateInstance(int style, Locale aLocale) a method in DateFormat Class..

Hope this helps..


OCPJP
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36508
    
  16
And welcome to the Ranch

You are quite a recent arrival if you have only waited 7 years for your first post.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7063
    
  16

Jammie Jamloki wrote:Is there any generic way ?

Well, in theory:should work; but I'm darned if I can get it working on my machine in Eclipse (it throws a ParseException).

It works just fine if I use Locale.UK and "16 dec. 2012 08:55:55" though, so I suspect it has something to do with either:
(a) the Locales that my machine/Eclipse supports, or
(b) the default character set that it's using.

If I get it working, I'll post my findings.

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3169
    
  10
I forgot DateFormat was abstract. Using SimpleDateFormat and specifying the Locale in the constructor is probably simpler than my earlier suggestion (assuming you can get it to work of course).
Richard Tookey
Ranch Hand

Joined: Aug 27, 2012
Posts: 960
    
  10

Winston Gutkowski wrote:
If I get it working, I'll post my findings.


Interesting - if I use your code but use Décembre it works but I can't get any of the French month abbreviations to work.Of course one could always take the pragmatic approach and use a pre-processor to convert the abbreviations to the standard French months.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Parsing locale specific Datetime String
 
Similar Threads
Date to be returned as a locale specific string
ResourceBundle
resources.properties
How to set the locale in JSR 168 API portlet?(using wps 6.1)
<s:date name="%{new java.util.Date()}" /> formatDate & i18nInteceptor