You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2007/08/31 22:31:44 UTC
svn commit: r571564 -
/geronimo/sandbox/gshell/trunk/gshell-common/src/main/java/org/apache/geronimo/gshell/common/DateUtils.java
Author: jdillon
Date: Fri Aug 31 13:31:44 2007
New Revision: 571564
URL: http://svn.apache.org/viewvc?rev=571564&view=rev
Log:
Minor opt
Modified:
geronimo/sandbox/gshell/trunk/gshell-common/src/main/java/org/apache/geronimo/gshell/common/DateUtils.java
Modified: geronimo/sandbox/gshell/trunk/gshell-common/src/main/java/org/apache/geronimo/gshell/common/DateUtils.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-common/src/main/java/org/apache/geronimo/gshell/common/DateUtils.java?rev=571564&r1=571563&r2=571564&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-common/src/main/java/org/apache/geronimo/gshell/common/DateUtils.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-common/src/main/java/org/apache/geronimo/gshell/common/DateUtils.java Fri Aug 31 13:31:44 2007
@@ -675,9 +675,9 @@
// ----------------- Fix for LANG-59 ----------------------- END ----------------
boolean roundUp = false;
- for (int i = 0; i < fields.length; i++) {
- for (int j = 0; j < fields[i].length; j++) {
- if (fields[i][j] == field) {
+ for (int[] field1 : fields) {
+ for (int aField1 : field1) {
+ if (aField1 == field) {
//This is our field... we stop looping
if (round && roundUp) {
if (field == DateUtils.SEMI_MONTH) {
@@ -693,7 +693,7 @@
} else {
//We need at add one to this field since the
// last number causes us to round up
- val.add(fields[i][0], 1);
+ val.add(field1[0], 1);
}
}
return;
@@ -705,7 +705,7 @@
//These are special types of fields that require different rounding rules
switch (field) {
case DateUtils.SEMI_MONTH:
- if (fields[i][0] == Calendar.DATE) {
+ if (field1[0] == Calendar.DATE) {
//If we're going to drop the DATE field's value,
// we want to do this our own way.
//We need to subtrace 1 since the date has a minimum of 1
@@ -721,7 +721,7 @@
}
break;
case Calendar.AM_PM:
- if (fields[i][0] == Calendar.HOUR_OF_DAY) {
+ if (field1[0] == Calendar.HOUR_OF_DAY) {
//If we're going to drop the HOUR field's value,
// we want to do this our own way.
offset = val.get(Calendar.HOUR_OF_DAY);
@@ -734,16 +734,16 @@
break;
}
if (!offsetSet) {
- int min = val.getActualMinimum(fields[i][0]);
- int max = val.getActualMaximum(fields[i][0]);
+ int min = val.getActualMinimum(field1[0]);
+ int max = val.getActualMaximum(field1[0]);
//Calculate the offset from the minimum allowed value
- offset = val.get(fields[i][0]) - min;
+ offset = val.get(field1[0]) - min;
//Set roundUp if this is more than half way between the minimum and maximum
roundUp = offset > ((max - min) / 2);
}
//We need to remove this field
if (offset != 0) {
- val.set(fields[i][0], val.get(fields[i][0]) - offset);
+ val.set(field1[0], val.get(field1[0]) - offset);
}
}
throw new IllegalArgumentException("The field " + field + " is not supported");
@@ -812,8 +812,8 @@
if (focus == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar start = null;
- Calendar end = null;
+ Calendar start;
+ Calendar end;
int startCutoff = Calendar.SUNDAY;
int endCutoff = Calendar.SATURDAY;
switch (rangeStyle) {