JDK-4833268 : API: remove calendar system assumptions from DateFormat/SimpleDateFormat
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 1.4.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2003-03-17
  • Updated: 2017-05-16
  • Resolved: 2005-08-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b48Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
DateFormat/SimpleDateFormat doesn't support Buddhist Era with BuddhistCalendar in non-Thai locales. The following sample program demonstrates the problem.

--
import java.util.*;
import java.text.*;

public class FormatBuddhistCalendar {

    public static void main(String[] args) {
	Calendar cal = Calendar.getInstance(new Locale("th", "TH"));
	SimpleDateFormat fmt = new SimpleDateFormat("G yyyy.MM.dd", Locale.US);
	fmt.setCalendar(cal);
	System.out.println(fmt.format(new Date()));
    }
}

--
Output:

AD 2546.03.17

The era must be "B.E.".

###@###.### 2003-03-17

Comments
EVALUATION Currently, there's no mechanism to support non-GregorainCalendar. ###@###.### 2003-03-17 The calendar related resources, such as era names, must be organized per calendar system. Also we need methods to get calendar specific display names, such as Calendar.getDisplayName(int field, int format). ###@###.### 2005-03-16 02:20:52 GMT For parsing, we need Calendar.getDisplayNames(int field, int style, Locale locale) that returns a Map<String,Integer> containing pairs of display names of field and their values, such as "January" -> Calendar.JANUARY. ###@###.### 2005-05-10 09:56:53 GMT
10-05-2005