jQuery in Action, 2nd edition*
The moose likes Java in General and the fly likes Customized date separator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Customized date separator" Watch "Customized date separator" New topic
Author

Customized date separator

Suman Mummaneni
Ranch Hand

Joined: Dec 14, 2004
Posts: 87
Hi ,

Is there any way to get the customized date separator that has been set by the user in the windows regional settings. As the regional settings provides an option to customize the date separator and other date characters the Locale object does not retrieve the accordingly set characters it only returns the defaults of that Locale


Suman Mummaneni
Bangalore
India
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

This may not be the ideal solution, but if you're looking for information specific to Windows regional settings, such as Windows Local information, you can read it very easily from the Windows Registry.

All such options for the current logged in user are stored in the registry key:

HKEY_CURRENT_USER\Control Panel\International

If you use Regedit.exe to open this by hand, its not vary difficult to discern. For example, "sDate" controls the date separate, "sShortDate" controls the date format. As for how to read the data from the Windows Registry, can't really help you there, there's numerous tips and tools online for it such as http://www.rgagnon.com/javadetails/java-0480.html that I just found using Google.

Hope this helps!


My Blog: Down Home Country Coding with Scott Selikoff
Suman Mummaneni
Ranch Hand

Joined: Dec 14, 2004
Posts: 87
Hi Scott,

Thankyou very much for the post. I have solved the problem using JNI. I was using JNI in the project so I added new method to the dll to return windows date and time format. The solution that you have proposed is also good. It's a work around solution with out using JNI.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

No problem, I figured there was a more elegent way, but I've never accessed the registry using java, so I'm glad you found the better way. Good luck!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Customized date separator