Results 1 to 3 of 3
- 02-27-2009, 10:14 AM #1
Member
- Join Date
- Dec 2007
- Posts
- 22
- Rep Power
- 0
Java Locale Date Display Diff Format Prob
I have written the below program to take the System Locale Language and the System Locale Country. Then Created the Locale Object and used it to format the Input Date to the Date of the Locale of the Client System. But there seems to be a difference in the formats displayed by the below Java Program as opposed to what is shown in my regional Settings as shown in the Screen shot.
OutputJava Code:import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Locale; public class DateUtilEx { public static void main(String args[]) { String dateInGermanFormat = "27.02.2009"; // Input Date in German Date Format String userLang = System.getProperty("user.language"); String userCountry = System.getProperty("user.country"); System.out.println("User Language : " + userLang + "\t" + "userCountry : " + userCountry); Locale locale = new Locale(userLang, userCountry); DateFormat localeFormatter = DateFormat.getDateInstance( DateFormat.SHORT, locale); SimpleDateFormat germanFormatter = new SimpleDateFormat("dd.MM.yyyy"); try { System.out.println(localeFormatter.format(germanFormatter .parse(dateInGermanFormat))); } catch (ParseException e) { e.printStackTrace(); } } }
User Language : en userCountry : US
2/27/09
What I see in the Regional Settings (in the Screenshot) - Short Date: 02/27/2009
The year part is just 2 digits in the Java Program. Can you help me with this?
- 03-02-2009, 07:18 AM #2
Member
- Join Date
- Dec 2007
- Posts
- 22
- Rep Power
- 0
- 03-05-2009, 02:05 PM #3
Similar Threads
-
Date Format
By learnspring in forum New To JavaReplies: 1Last Post: 11-16-2008, 05:16 PM -
Simple Date Format
By arimakidd in forum Java AppletsReplies: 1Last Post: 09-29-2008, 04:46 AM -
How to format the date in particular pattern
By Java Tip in forum java.textReplies: 0Last Post: 04-04-2008, 02:35 PM -
How to format the date in particular pattern
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 09:28 PM -
Date format display in CSV file after exporting
By latha in forum Advanced JavaReplies: 0Last Post: 08-03-2007, 08:09 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks