2 Replies Latest reply on Mar 29, 2008 3:22 PM by darrylburke

    Java Date Format

    807591
      Hi all,

      I find a mismatch in the date format set in my laptop and the DateFormat API. I have set the Locale as Uzbek(Cyrillic) with the date format as dd.MM.yyyy in my laptop and started my java program to get the dateformat using the following API -
      DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
      return dateFormatter.format(date);

      When I run the above code, the date gets displayed as mm/dd/yy format.

      Please let me know where the mistake is and why there is a mismatch in the format getting displayed.

      Thanks in advance!!
        • 1. Re: Java Date Format
          807591
          Taken from the API doc.:



          +The exact result depends on the locale, but generally:+


          +<LI>SHORT is completely numeric, such as 12.13.52 or 3:30pm</LI>+

          Why did you expect a different behavior?
          • 2. Re: Java Date Format
            darrylburke
            What do you get if you use this form?
            DateFormat.getDateInstance(DateFormat.SHORT);
            (Gets the date formatter with the given formatting style for the default locale.)

            Also, what do these return?
            Locale.getDefault ().getDisplayCountry ()
            Locale.getDefault ().getDisplayLanguage()
            Locale.getDefault ().getDisplayName()
            db