aspose file tools*
The moose likes Java in General and the fly likes Sun classes. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Sun classes. " Watch "Sun classes. " New topic
Author

Sun classes.

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 757
Hi,

One of the Utility class in our project is using Sun class to load some date time pattern i am not sure what it does as shown in the below code snippet.

This was working fine till JDK 1.5, but now i am migrating entire application to JDK 1.6 and this class seems to have changed. []



I want to remove this code which uses Sun class LocaleData but i am not able to find any alternative as i am not sure what it does exactly.

I tried to debug it on JDK 1.5 and for en_US locale it brings up the below String array

[HH:mm:ss 'o''clock' z, HH:mm:ss z, HH:mm:ss, HH:mm, EEEE, d MMMM yyyy, dd MMMM yyyy, dd-MMM-yyyy, dd/MM/yy, {1} {0}]

Is there any alternative to this ?

Jigar Naik


Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

What package was that class in?

edit Apparently continued from here. Jigar, when you post a follow-up question in a new thread, please provide a link to the earlier discussion to avoid repetition of advice.


luck, db
There are no new questions, but there may be new answers.
Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 757
it was in sun.text.resources.LocaleData

I found the alternative; copies those properties file containing patterns from Open JDK, and reading it through ResourceBundle.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

It's good that you found a solution, but please see my edit in the first response, and my response on your earlier thread.
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2854
    
  11

Well, that's the problem with badly written code. It's tough for maintainers. You'll have to examine the whole code base and see how they are using those patterns. They are probably using the patterns to instantiate SimpleDateFormat instances. If you're lucky, they're setting these all up in the same place. You can change those to DateFormat.getXxxInstance() calls, like DateFormat.getDateInstance(SHORT, myLocale).

On the other hand, you could just make literal Strings matching what you found in Java 1.5, and shove them in your patternTable. That kicks the rewriting job down the road a bit, but still leaves you with badly written code.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sun classes.