Solved

How to control the environmental format of SimpleDateFormat

Posted on 2004-10-18
3
208 Views
Last Modified: 2010-03-31
Hi,
I'm using SimpleDateFormat in this way wherever I 'go':
   /**
    *  Returns the <b>given</b> date formatted as <b>dd-MMM-yyyy</b> (day-month-year).
    *
    * @param d the date to be formatted.
    * @return the formatted result as a String.
    */
   public static String getDate(Date d)
   {
      return(new SimpleDateFormat("dd-MMM-yyyy").format(d));
   }
However, on certain machines this gives "19-Oct-2004" (what I prefer),
on other machines "19-okt-2004" or worse, due to international settings.
For various reasons I want to standardise on the 'English' format.
How do I force these things?
;JOOP!
0
Comment
Question by:sciuriware
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 12345115
try specifying the Locale in the SDF ctor.
0
 
LVL 24

Author Comment

by:sciuriware
ID: 12345171
The first, the correct, the shortest and the abbreviated answer, always from YOU!
Do you ever sleep?








:>)
0
 
LVL 92

Expert Comment

by:objects
ID: 12345197
:)
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jar file executable 12 51
more than one jdk and one jre 1 41
tomcat administrtor 12 46
printf performancy 11 32
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question