mirror of
https://github.com/apache/commons-lang.git
synced 2025-03-06 16:09:22 +00:00
replace tabs with spaces
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1668515 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bbfa8eb7df
commit
8bc91a95f9
@ -99,7 +99,7 @@ public class FastDateParser implements DateParser, Serializable {
|
||||
*
|
||||
* Use {@link FastDateFormat#getInstance(String, TimeZone, Locale)} or another variation of the
|
||||
* factory methods of {@link FastDateFormat} to get a cached FastDateParser instance.
|
||||
*
|
||||
*
|
||||
* @param pattern non-null {@link java.text.SimpleDateFormat} compatible
|
||||
* pattern
|
||||
* @param timeZone non-null time zone to use
|
||||
@ -529,7 +529,7 @@ private Strategy getStrategy(final String formatField, final Calendar definingCa
|
||||
case 'y':
|
||||
return formatField.length()>2 ?LITERAL_YEAR_STRATEGY :ABBREVIATED_YEAR_STRATEGY;
|
||||
case 'X':
|
||||
return ISO8601TimeZoneStrategy.getStrategy(formatField.length());
|
||||
return ISO8601TimeZoneStrategy.getStrategy(formatField.length());
|
||||
case 'Z':
|
||||
if (formatField.equals("ZZ")) {
|
||||
return ISO_8601_STRATEGY;
|
||||
@ -840,10 +840,10 @@ else if(value.startsWith("GMT")) {
|
||||
|
||||
private static class ISO8601TimeZoneStrategy extends Strategy {
|
||||
// Z, +hh, -hh, +hhmm, -hhmm, +hh:mm or -hh:mm
|
||||
private final String pattern;
|
||||
private final String pattern;
|
||||
|
||||
ISO8601TimeZoneStrategy(String pattern) {
|
||||
this.pattern = pattern;
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -871,18 +871,18 @@ void setCalendar(FastDateParser parser, Calendar cal, String value) {
|
||||
private static final Strategy ISO_8601_2_STRATEGY = new ISO8601TimeZoneStrategy("(Z|(?:[+-]\\d{2}\\d{2}))");
|
||||
private static final Strategy ISO_8601_3_STRATEGY = new ISO8601TimeZoneStrategy("(Z|(?:[+-]\\d{2}(?::)\\d{2}))");
|
||||
|
||||
static Strategy getStrategy(int tokenLen) {
|
||||
switch(tokenLen) {
|
||||
case 1:
|
||||
return ISO_8601_1_STRATEGY;
|
||||
case 2:
|
||||
return ISO_8601_2_STRATEGY;
|
||||
case 3:
|
||||
return ISO_8601_3_STRATEGY;
|
||||
default:
|
||||
throw new IllegalArgumentException("invalid number of X");
|
||||
}
|
||||
}
|
||||
static Strategy getStrategy(int tokenLen) {
|
||||
switch(tokenLen) {
|
||||
case 1:
|
||||
return ISO_8601_1_STRATEGY;
|
||||
case 2:
|
||||
return ISO_8601_2_STRATEGY;
|
||||
case 3:
|
||||
return ISO_8601_3_STRATEGY;
|
||||
default:
|
||||
throw new IllegalArgumentException("invalid number of X");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final Strategy NUMBER_MONTH_STRATEGY = new NumberStrategy(Calendar.MONTH) {
|
||||
|
@ -272,7 +272,7 @@ protected List<Rule> parsePattern() {
|
||||
rule = selectNumberRule(Calendar.HOUR, tokenLen);
|
||||
break;
|
||||
case 'X': // ISO 8601
|
||||
rule = Iso8601_Rule.getRule(tokenLen);
|
||||
rule = Iso8601_Rule.getRule(tokenLen);
|
||||
break;
|
||||
case 'z': // time zone (text)
|
||||
if (tokenLen >= 4) {
|
||||
@ -590,10 +590,10 @@ private void readObject(final ObjectInputStream in) throws IOException, ClassNot
|
||||
init();
|
||||
}
|
||||
|
||||
private static void appendDigits(final StringBuffer buffer, final int value) {
|
||||
buffer.append((char)(value / 10 + '0'));
|
||||
buffer.append((char)(value % 10 + '0'));
|
||||
}
|
||||
private static void appendDigits(final StringBuffer buffer, final int value) {
|
||||
buffer.append((char)(value / 10 + '0'));
|
||||
buffer.append((char)(value % 10 + '0'));
|
||||
}
|
||||
|
||||
// Rules
|
||||
//-----------------------------------------------------------------------
|
||||
@ -824,7 +824,7 @@ public final void appendTo(final StringBuffer buffer, final int value) {
|
||||
if (value < 10) {
|
||||
buffer.append((char)(value + '0'));
|
||||
} else {
|
||||
appendDigits(buffer, value);
|
||||
appendDigits(buffer, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1130,7 +1130,7 @@ static String getTimeZoneDisplay(final TimeZone tz, final boolean daylight, fina
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* <p>Inner class to output a time zone name.</p>
|
||||
*/
|
||||
private static class TimeZoneNameRule implements Rule {
|
||||
@ -1246,26 +1246,26 @@ public void appendTo(final StringBuffer buffer, final Calendar calendar) {
|
||||
* or {@code +/-HH:MM}.</p>
|
||||
*/
|
||||
private static class Iso8601_Rule implements Rule {
|
||||
|
||||
// Sign TwoDigitHours or Z
|
||||
|
||||
// Sign TwoDigitHours or Z
|
||||
static final Iso8601_Rule ISO8601_HOURS = new Iso8601_Rule(3);
|
||||
// Sign TwoDigitHours Minutes or Z
|
||||
// Sign TwoDigitHours Minutes or Z
|
||||
static final Iso8601_Rule ISO8601_HOURS_MINUTES = new Iso8601_Rule(5);
|
||||
// Sign TwoDigitHours : Minutes or Z
|
||||
// Sign TwoDigitHours : Minutes or Z
|
||||
static final Iso8601_Rule ISO8601_HOURS_COLON_MINUTES = new Iso8601_Rule(6);
|
||||
|
||||
static Iso8601_Rule getRule(int tokenLen) {
|
||||
switch(tokenLen) {
|
||||
case 1:
|
||||
return Iso8601_Rule.ISO8601_HOURS;
|
||||
case 2:
|
||||
return Iso8601_Rule.ISO8601_HOURS_MINUTES;
|
||||
case 3:
|
||||
return Iso8601_Rule.ISO8601_HOURS_COLON_MINUTES;
|
||||
default:
|
||||
throw new IllegalArgumentException("invalid number of X");
|
||||
}
|
||||
}
|
||||
switch(tokenLen) {
|
||||
case 1:
|
||||
return Iso8601_Rule.ISO8601_HOURS;
|
||||
case 2:
|
||||
return Iso8601_Rule.ISO8601_HOURS_MINUTES;
|
||||
case 3:
|
||||
return Iso8601_Rule.ISO8601_HOURS_COLON_MINUTES;
|
||||
default:
|
||||
throw new IllegalArgumentException("invalid number of X");
|
||||
}
|
||||
}
|
||||
|
||||
final int length;
|
||||
|
||||
@ -1275,7 +1275,7 @@ static Iso8601_Rule getRule(int tokenLen) {
|
||||
* @param length The number of characters in output (unless Z is output)
|
||||
*/
|
||||
Iso8601_Rule(final int length) {
|
||||
this.length = length;
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1292,7 +1292,7 @@ public int estimateLength() {
|
||||
@Override
|
||||
public void appendTo(final StringBuffer buffer, final Calendar calendar) {
|
||||
int zoneOffset = calendar.get(Calendar.ZONE_OFFSET);
|
||||
if (zoneOffset == 0) {
|
||||
if (zoneOffset == 0) {
|
||||
buffer.append("Z");
|
||||
return;
|
||||
}
|
||||
@ -1310,7 +1310,7 @@ public void appendTo(final StringBuffer buffer, final Calendar calendar) {
|
||||
appendDigits(buffer, hours);
|
||||
|
||||
if (length<5) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (length==6) {
|
||||
|
@ -558,62 +558,62 @@ public void testLang996() throws ParseException {
|
||||
assertEquals(expected.getTime(), fdp.parse("14May2014"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void test1806Argument() {
|
||||
getInstance("XXXX");
|
||||
}
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void test1806Argument() {
|
||||
getInstance("XXXX");
|
||||
}
|
||||
|
||||
private static Calendar initializeCalendar(TimeZone tz) {
|
||||
Calendar cal = Calendar.getInstance(tz);
|
||||
cal.set(Calendar.YEAR, 2001);
|
||||
cal.set(Calendar.MONTH, 1); // not daylight savings
|
||||
cal.set(Calendar.DAY_OF_MONTH, 4);
|
||||
cal.set(Calendar.HOUR_OF_DAY, 12);
|
||||
cal.set(Calendar.MINUTE, 8);
|
||||
cal.set(Calendar.SECOND, 56);
|
||||
cal.set(Calendar.MILLISECOND, 235);
|
||||
return cal;
|
||||
}
|
||||
private static Calendar initializeCalendar(TimeZone tz) {
|
||||
Calendar cal = Calendar.getInstance(tz);
|
||||
cal.set(Calendar.YEAR, 2001);
|
||||
cal.set(Calendar.MONTH, 1); // not daylight savings
|
||||
cal.set(Calendar.DAY_OF_MONTH, 4);
|
||||
cal.set(Calendar.HOUR_OF_DAY, 12);
|
||||
cal.set(Calendar.MINUTE, 8);
|
||||
cal.set(Calendar.SECOND, 56);
|
||||
cal.set(Calendar.MILLISECOND, 235);
|
||||
return cal;
|
||||
}
|
||||
|
||||
private static enum Expected1806 {
|
||||
India(INDIA, "+05", "+0530", "+05:30", true),
|
||||
Greenwich(GMT, "Z", "Z", "Z", false),
|
||||
NewYork(NEW_YORK, "-05", "-0500", "-05:00", false);
|
||||
private static enum Expected1806 {
|
||||
India(INDIA, "+05", "+0530", "+05:30", true),
|
||||
Greenwich(GMT, "Z", "Z", "Z", false),
|
||||
NewYork(NEW_YORK, "-05", "-0500", "-05:00", false);
|
||||
|
||||
private Expected1806(TimeZone zone, String one, String two, String three, boolean hasHalfHourOffset) {
|
||||
this.zone = zone;
|
||||
this.one = one;
|
||||
this.two = two;
|
||||
this.three = three;
|
||||
this.offset = hasHalfHourOffset ?30*60*1000 :0;
|
||||
}
|
||||
private Expected1806(TimeZone zone, String one, String two, String three, boolean hasHalfHourOffset) {
|
||||
this.zone = zone;
|
||||
this.one = one;
|
||||
this.two = two;
|
||||
this.three = three;
|
||||
this.offset = hasHalfHourOffset ?30*60*1000 :0;
|
||||
}
|
||||
|
||||
final TimeZone zone;
|
||||
final String one;
|
||||
final String two;
|
||||
final String three;
|
||||
final long offset;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1806() throws ParseException {
|
||||
String formatStub = "yyyy-MM-dd'T'HH:mm:ss.SSS";
|
||||
String dateStub = "2001-02-04T12:08:56.235";
|
||||
|
||||
for (Expected1806 trial : Expected1806.values()) {
|
||||
Calendar cal = initializeCalendar(trial.zone);
|
||||
final TimeZone zone;
|
||||
final String one;
|
||||
final String two;
|
||||
final String three;
|
||||
final long offset;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1806() throws ParseException {
|
||||
String formatStub = "yyyy-MM-dd'T'HH:mm:ss.SSS";
|
||||
String dateStub = "2001-02-04T12:08:56.235";
|
||||
|
||||
for (Expected1806 trial : Expected1806.values()) {
|
||||
Calendar cal = initializeCalendar(trial.zone);
|
||||
|
||||
String message = trial.zone.getDisplayName()+";";
|
||||
|
||||
DateParser parser = getInstance(formatStub+"X", trial.zone);
|
||||
assertEquals(message+trial.one, cal.getTime().getTime(), parser.parse(dateStub+trial.one).getTime()-trial.offset);
|
||||
String message = trial.zone.getDisplayName()+";";
|
||||
|
||||
DateParser parser = getInstance(formatStub+"X", trial.zone);
|
||||
assertEquals(message+trial.one, cal.getTime().getTime(), parser.parse(dateStub+trial.one).getTime()-trial.offset);
|
||||
|
||||
parser = getInstance(formatStub+"XX", trial.zone);
|
||||
assertEquals(message+trial.two, cal.getTime(), parser.parse(dateStub+trial.two));
|
||||
parser = getInstance(formatStub+"XX", trial.zone);
|
||||
assertEquals(message+trial.two, cal.getTime(), parser.parse(dateStub+trial.two));
|
||||
|
||||
parser = getInstance(formatStub+"XXX", trial.zone);
|
||||
assertEquals(message+trial.three, cal.getTime(), parser.parse(dateStub+trial.three));
|
||||
}
|
||||
}
|
||||
parser = getInstance(formatStub+"XXX", trial.zone);
|
||||
assertEquals(message+trial.three, cal.getTime(), parser.parse(dateStub+trial.three));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -276,54 +276,54 @@ public void testTimeZoneAsZ() throws Exception {
|
||||
assertEquals("+00:00", colonFormat.format(c));
|
||||
}
|
||||
|
||||
private static Calendar initializeCalendar(TimeZone tz) {
|
||||
Calendar cal = Calendar.getInstance(tz);
|
||||
cal.set(Calendar.YEAR, 2001);
|
||||
cal.set(Calendar.MONTH, 1); // not daylight savings
|
||||
cal.set(Calendar.DAY_OF_MONTH, 4);
|
||||
cal.set(Calendar.HOUR_OF_DAY, 12);
|
||||
cal.set(Calendar.MINUTE, 8);
|
||||
cal.set(Calendar.SECOND, 56);
|
||||
cal.set(Calendar.MILLISECOND, 235);
|
||||
return cal;
|
||||
}
|
||||
private static Calendar initializeCalendar(TimeZone tz) {
|
||||
Calendar cal = Calendar.getInstance(tz);
|
||||
cal.set(Calendar.YEAR, 2001);
|
||||
cal.set(Calendar.MONTH, 1); // not daylight savings
|
||||
cal.set(Calendar.DAY_OF_MONTH, 4);
|
||||
cal.set(Calendar.HOUR_OF_DAY, 12);
|
||||
cal.set(Calendar.MINUTE, 8);
|
||||
cal.set(Calendar.SECOND, 56);
|
||||
cal.set(Calendar.MILLISECOND, 235);
|
||||
return cal;
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void test1806Argument() {
|
||||
getInstance("XXXX");
|
||||
}
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void test1806Argument() {
|
||||
getInstance("XXXX");
|
||||
}
|
||||
|
||||
private static enum Expected1806 {
|
||||
India(INDIA, "+05", "+0530", "+05:30"), Greenwich(GMT, "Z", "Z", "Z"), NewYork(
|
||||
NEW_YORK, "-05", "-0500", "-05:00");
|
||||
private static enum Expected1806 {
|
||||
India(INDIA, "+05", "+0530", "+05:30"), Greenwich(GMT, "Z", "Z", "Z"), NewYork(
|
||||
NEW_YORK, "-05", "-0500", "-05:00");
|
||||
|
||||
private Expected1806(TimeZone zone, String one, String two, String three) {
|
||||
this.zone = zone;
|
||||
this.one = one;
|
||||
this.two = two;
|
||||
this.three = three;
|
||||
}
|
||||
private Expected1806(TimeZone zone, String one, String two, String three) {
|
||||
this.zone = zone;
|
||||
this.one = one;
|
||||
this.two = two;
|
||||
this.three = three;
|
||||
}
|
||||
|
||||
final TimeZone zone;
|
||||
final String one;
|
||||
final String two;
|
||||
final String three;
|
||||
}
|
||||
final TimeZone zone;
|
||||
final String one;
|
||||
final String two;
|
||||
final String three;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test1806() throws ParseException {
|
||||
for (Expected1806 trial : Expected1806.values()) {
|
||||
Calendar cal = initializeCalendar(trial.zone);
|
||||
@Test
|
||||
public void test1806() throws ParseException {
|
||||
for (Expected1806 trial : Expected1806.values()) {
|
||||
Calendar cal = initializeCalendar(trial.zone);
|
||||
|
||||
DatePrinter printer = getInstance("X", trial.zone);
|
||||
assertEquals(trial.one, printer.format(cal));
|
||||
DatePrinter printer = getInstance("X", trial.zone);
|
||||
assertEquals(trial.one, printer.format(cal));
|
||||
|
||||
printer = getInstance("XX", trial.zone);
|
||||
assertEquals(trial.two, printer.format(cal));
|
||||
printer = getInstance("XX", trial.zone);
|
||||
assertEquals(trial.two, printer.format(cal));
|
||||
|
||||
printer = getInstance("XXX", trial.zone);
|
||||
assertEquals(trial.three, printer.format(cal));
|
||||
}
|
||||
}
|
||||
printer = getInstance("XXX", trial.zone);
|
||||
assertEquals(trial.three, printer.format(cal));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user