Removed ChineseDateFormat stuff because the Chinese
calendar doesn't work. X-SVN-Rev: 853
This commit is contained in:
parent
f2ab64247f
commit
5e2912446e
@ -1,114 +0,0 @@
|
||||
/*
|
||||
* $RCSfile: ChineseDateFormat.java,v $ $Revision: 1.1 $ $Date: 2000/02/10 06:25:49 $
|
||||
*/
|
||||
|
||||
package com.ibm.text;
|
||||
|
||||
import com.ibm.util.ChineseCalendar;
|
||||
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.lang.ClassNotFoundException;
|
||||
import java.lang.StringIndexOutOfBoundsException;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.FieldPosition;
|
||||
import java.text.ParsePosition;
|
||||
|
||||
import java.util.TimeZone;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.SimpleTimeZone;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Hashtable;
|
||||
|
||||
|
||||
public class ChineseDateFormat extends SimpleDateFormat {
|
||||
|
||||
public ChineseDateFormat(ChineseCalendar cal, int dateStyle, int timeStyle,
|
||||
Locale loc)
|
||||
{
|
||||
super(patternHelper(dateStyle, timeStyle, loc),
|
||||
new ChineseDateSymbols(loc));
|
||||
setCalendar(cal);
|
||||
}
|
||||
|
||||
private static String patternHelper(int dateStyle, int timeStyle, Locale loc)
|
||||
{
|
||||
// PERF: bundle is loaded twice; symbols loaded it too
|
||||
ResourceBundle bundle = ResourceBundle.getBundle(
|
||||
"com.ibm.util.resources.ChineseCalendarSymbols");
|
||||
|
||||
String[] patterns = bundle.getStringArray("DateTimePatterns");
|
||||
|
||||
String pattern = null;
|
||||
if ((timeStyle >= 0) && (dateStyle >= 0)) {
|
||||
Object[] dateTimeArgs = { patterns[timeStyle],
|
||||
patterns[dateStyle + 4] };
|
||||
pattern = MessageFormat.format(patterns[8], dateTimeArgs);
|
||||
}
|
||||
else if (timeStyle >= 0) {
|
||||
pattern = patterns[timeStyle];
|
||||
}
|
||||
else if (dateStyle >= 0) {
|
||||
pattern = patterns[dateStyle + 4];
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("No date or time style specified");
|
||||
}
|
||||
return pattern;
|
||||
}
|
||||
|
||||
// Private member function that does the real date/time formatting.
|
||||
protected String subFormat(char ch, int count, int beginOffset,
|
||||
FieldPosition pos, DateFormatSymbols formatData)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
ChineseDateSymbols symbols = (ChineseDateSymbols)formatData;
|
||||
|
||||
int patternCharIndex = -1;
|
||||
int maxIntCount = Integer.MAX_VALUE;
|
||||
String result = null;
|
||||
|
||||
if ((patternCharIndex = patternChars.indexOf(ch)) == -1) {
|
||||
return super.subFormat(ch, count, beginOffset, pos, formatData);
|
||||
}
|
||||
|
||||
int field = PATTERN_INDEX_TO_CALENDAR_FIELD[patternCharIndex];
|
||||
int value = calendar.get(field);
|
||||
|
||||
switch (patternCharIndex) {
|
||||
case '0': // ERA
|
||||
result = zeroPaddingNumber(value, count, maxIntCount);
|
||||
break;
|
||||
case '1': // LEAP_MONTH
|
||||
result = zeroPaddingNumber(value, count, maxIntCount);
|
||||
break;
|
||||
case '2': // SOLAR_TERM
|
||||
result = zeroPaddingNumber(value, count, maxIntCount);
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cache to hold the DateTimePatterns of a Locale.
|
||||
*/
|
||||
private static Hashtable cachedLocaleData = new Hashtable(3);
|
||||
|
||||
static final String patternChars = "GLT";
|
||||
|
||||
// Map index into pattern character string to Calendar field number
|
||||
private static final int[] PATTERN_INDEX_TO_CALENDAR_FIELD =
|
||||
{
|
||||
ChineseCalendar.LEAP_MONTH, ChineseCalendar.SOLAR_TERM,
|
||||
};
|
||||
|
||||
};
|
@ -1,114 +0,0 @@
|
||||
/*
|
||||
* $RCSfile: ChineseDateFormat.java,v $ $Revision: 1.1 $ $Date: 2000/02/10 06:25:49 $
|
||||
*/
|
||||
|
||||
package com.ibm.text;
|
||||
|
||||
import com.ibm.util.ChineseCalendar;
|
||||
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.lang.ClassNotFoundException;
|
||||
import java.lang.StringIndexOutOfBoundsException;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.FieldPosition;
|
||||
import java.text.ParsePosition;
|
||||
|
||||
import java.util.TimeZone;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.SimpleTimeZone;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Hashtable;
|
||||
|
||||
|
||||
public class ChineseDateFormat extends SimpleDateFormat {
|
||||
|
||||
public ChineseDateFormat(ChineseCalendar cal, int dateStyle, int timeStyle,
|
||||
Locale loc)
|
||||
{
|
||||
super(patternHelper(dateStyle, timeStyle, loc),
|
||||
new ChineseDateSymbols(loc));
|
||||
setCalendar(cal);
|
||||
}
|
||||
|
||||
private static String patternHelper(int dateStyle, int timeStyle, Locale loc)
|
||||
{
|
||||
// PERF: bundle is loaded twice; symbols loaded it too
|
||||
ResourceBundle bundle = ResourceBundle.getBundle(
|
||||
"com.ibm.util.resources.ChineseCalendarSymbols");
|
||||
|
||||
String[] patterns = bundle.getStringArray("DateTimePatterns");
|
||||
|
||||
String pattern = null;
|
||||
if ((timeStyle >= 0) && (dateStyle >= 0)) {
|
||||
Object[] dateTimeArgs = { patterns[timeStyle],
|
||||
patterns[dateStyle + 4] };
|
||||
pattern = MessageFormat.format(patterns[8], dateTimeArgs);
|
||||
}
|
||||
else if (timeStyle >= 0) {
|
||||
pattern = patterns[timeStyle];
|
||||
}
|
||||
else if (dateStyle >= 0) {
|
||||
pattern = patterns[dateStyle + 4];
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("No date or time style specified");
|
||||
}
|
||||
return pattern;
|
||||
}
|
||||
|
||||
// Private member function that does the real date/time formatting.
|
||||
protected String subFormat(char ch, int count, int beginOffset,
|
||||
FieldPosition pos, DateFormatSymbols formatData)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
ChineseDateSymbols symbols = (ChineseDateSymbols)formatData;
|
||||
|
||||
int patternCharIndex = -1;
|
||||
int maxIntCount = Integer.MAX_VALUE;
|
||||
String result = null;
|
||||
|
||||
if ((patternCharIndex = patternChars.indexOf(ch)) == -1) {
|
||||
return super.subFormat(ch, count, beginOffset, pos, formatData);
|
||||
}
|
||||
|
||||
int field = PATTERN_INDEX_TO_CALENDAR_FIELD[patternCharIndex];
|
||||
int value = calendar.get(field);
|
||||
|
||||
switch (patternCharIndex) {
|
||||
case '0': // ERA
|
||||
result = zeroPaddingNumber(value, count, maxIntCount);
|
||||
break;
|
||||
case '1': // LEAP_MONTH
|
||||
result = zeroPaddingNumber(value, count, maxIntCount);
|
||||
break;
|
||||
case '2': // SOLAR_TERM
|
||||
result = zeroPaddingNumber(value, count, maxIntCount);
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cache to hold the DateTimePatterns of a Locale.
|
||||
*/
|
||||
private static Hashtable cachedLocaleData = new Hashtable(3);
|
||||
|
||||
static final String patternChars = "GLT";
|
||||
|
||||
// Map index into pattern character string to Calendar field number
|
||||
private static final int[] PATTERN_INDEX_TO_CALENDAR_FIELD =
|
||||
{
|
||||
ChineseCalendar.LEAP_MONTH, ChineseCalendar.SOLAR_TERM,
|
||||
};
|
||||
|
||||
};
|
@ -1,87 +0,0 @@
|
||||
/*
|
||||
* $RCSfile: ChineseDateSymbols.java,v $ $Revision: 1.1 $ $Date: 2000/02/10 06:25:49 $
|
||||
*/
|
||||
|
||||
package com.ibm.text;
|
||||
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
class ChineseDateSymbols extends DateFormatSymbols {
|
||||
|
||||
public ChineseDateSymbols() {
|
||||
this(Locale.getDefault());
|
||||
}
|
||||
|
||||
public ChineseDateSymbols(Locale loc) {
|
||||
super(loc);
|
||||
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("com.ibm.util.resources.ChineseCalendarSymbols", loc);
|
||||
|
||||
try {
|
||||
String[] temp = bundle.getStringArray("DayNames");
|
||||
setWeekdays(temp);
|
||||
setShortWeekdays(temp);
|
||||
|
||||
temp = bundle.getStringArray("DayAbbreviations");
|
||||
setShortWeekdays( temp );
|
||||
}
|
||||
catch (MissingResourceException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
String[] temp = bundle.getStringArray("MonthNames");
|
||||
setMonths( temp );
|
||||
setShortMonths( temp );
|
||||
|
||||
temp = bundle.getStringArray("MonthAbbreviations");
|
||||
setShortMonths( temp );
|
||||
}
|
||||
catch (MissingResourceException e) {
|
||||
}
|
||||
|
||||
setEras( bundle.getStringArray("Eras") );
|
||||
|
||||
stemNames = bundle.getStringArray("StemNames");
|
||||
branchNames = bundle.getStringArray("BranchNames");
|
||||
termNames = bundle.getStringArray("TermNames");
|
||||
monthTypes = bundle.getStringArray("MonthTypes");
|
||||
|
||||
}
|
||||
|
||||
public String[] getStemNames() {
|
||||
return duplicate(stemNames);
|
||||
}
|
||||
|
||||
public String[] getBranchNames() {
|
||||
return duplicate(branchNames);
|
||||
}
|
||||
|
||||
public String[] getTermNames() {
|
||||
return duplicate(termNames);
|
||||
}
|
||||
|
||||
public String[] getMonthTypes() {
|
||||
return duplicate(monthTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones an array of Strings.
|
||||
* @param srcArray the source array to be cloned.
|
||||
* @param count the number of elements in the given source array.
|
||||
* @return a cloned array.
|
||||
*/
|
||||
private final String[] duplicate(String[] srcArray)
|
||||
{
|
||||
String[] dstArray = new String[srcArray.length];
|
||||
System.arraycopy(srcArray, 0, dstArray, 0, srcArray.length);
|
||||
return dstArray;
|
||||
}
|
||||
|
||||
private String[] stemNames;
|
||||
private String[] branchNames;
|
||||
private String[] termNames;
|
||||
private String[] monthTypes;
|
||||
};
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# @(#)$RCSfile: GNUmakefile,v $ $Revision: 1.1 $ $Date: 2000/02/16 23:39:56 $
|
||||
# @(#)$RCSfile: GNUmakefile,v $ $Revision: 1.2 $ $Date: 2000/02/28 01:10:40 $
|
||||
#
|
||||
|
||||
TOPDIR= ../../../..
|
||||
@ -9,9 +9,7 @@ include $(TOPDIR)/src/build/defs.gmk
|
||||
|
||||
SUBDIRS= resources components
|
||||
|
||||
FILES_java= $(TARGDIR)/ChineseDateFormat.java \
|
||||
$(TARGDIR)/ChineseDateSymbols.java \
|
||||
$(TARGDIR)/DateFormatSymbols.java \
|
||||
FILES_java= $(TARGDIR)/DateFormatSymbols.java \
|
||||
$(TARGDIR)/StringSearch.java \
|
||||
$(TARGDIR)/SearchIterator.java \
|
||||
$(TARGDIR)/SimpleDateFormat.java \
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# @(#)$RCSfile: makefile,v $ $Revision: 1.1 $ $Date: 2000/02/16 23:39:57 $
|
||||
# @(#)$RCSfile: makefile,v $ $Revision: 1.2 $ $Date: 2000/02/28 01:10:41 $
|
||||
#
|
||||
|
||||
TOPDIR= ../../../..
|
||||
@ -9,9 +9,7 @@ PACKAGE= com.ibm.text
|
||||
|
||||
SUBDIRS= resources components
|
||||
|
||||
FILES_java= $(TARGDIR)/ChineseDateFormat.java \
|
||||
$(TARGDIR)/ChineseDateSymbols.java \
|
||||
$(TARGDIR)/DateFormatSymbols.java \
|
||||
FILES_java= $(TARGDIR)/DateFormatSymbols.java \
|
||||
$(TARGDIR)/StringSearch.java \
|
||||
$(TARGDIR)/SearchIterator.java \
|
||||
$(TARGDIR)/SimpleDateFormat.java \
|
||||
|
Loading…
Reference in New Issue
Block a user