Java Code Examples for org.joda.time.DateTimeField#set()
The following examples show how to use
org.joda.time.DateTimeField#set() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Time_18_GJChronology_t.java From coming with MIT License | 5 votes |
public int getMaximumValue(ReadablePartial partial, int[] values) { Chronology chrono = GJChronology.getInstanceUTC(); long instant = 0L; for (int i = 0, isize = partial.size(); i < isize; i++) { DateTimeField field = partial.getFieldType(i).getField(chrono); if (values[i] <= field.getMaximumValue(instant)) { instant = field.set(instant, values[i]); } } return getMaximumValue(instant); }
Example 2
Source File: Time_18_GJChronology_s.java From coming with MIT License | 5 votes |
public int getMaximumValue(ReadablePartial partial, int[] values) { Chronology chrono = GJChronology.getInstanceUTC(); long instant = 0L; for (int i = 0, isize = partial.size(); i < isize; i++) { DateTimeField field = partial.getFieldType(i).getField(chrono); if (values[i] <= field.getMaximumValue(instant)) { instant = field.set(instant, values[i]); } } return getMaximumValue(instant); }
Example 3
Source File: Time_6_GJChronology_s.java From coming with MIT License | 5 votes |
public int getMaximumValue(ReadablePartial partial, int[] values) { Chronology chrono = GJChronology.getInstanceUTC(); long instant = 0L; for (int i = 0, isize = partial.size(); i < isize; i++) { DateTimeField field = partial.getFieldType(i).getField(chrono); if (values[i] <= field.getMaximumValue(instant)) { instant = field.set(instant, values[i]); } } return getMaximumValue(instant); }
Example 4
Source File: Time_6_GJChronology_t.java From coming with MIT License | 5 votes |
public int getMaximumValue(ReadablePartial partial, int[] values) { Chronology chrono = GJChronology.getInstanceUTC(); long instant = 0L; for (int i = 0, isize = partial.size(); i < isize; i++) { DateTimeField field = partial.getFieldType(i).getField(chrono); if (values[i] <= field.getMaximumValue(instant)) { instant = field.set(instant, values[i]); } } return getMaximumValue(instant); }
Example 5
Source File: GJChronology.java From astor with GNU General Public License v2.0 | 5 votes |
public int getMaximumValue(ReadablePartial partial, int[] values) { Chronology chrono = GJChronology.getInstanceUTC(); long instant = 0L; for (int i = 0, isize = partial.size(); i < isize; i++) { DateTimeField field = partial.getFieldType(i).getField(chrono); if (values[i] <= field.getMaximumValue(instant)) { instant = field.set(instant, values[i]); } } return getMaximumValue(instant); }
Example 6
Source File: GJChronology.java From astor with GNU General Public License v2.0 | 5 votes |
public int getMaximumValue(ReadablePartial partial, int[] values) { Chronology chrono = GJChronology.getInstanceUTC(); long instant = 0L; for (int i = 0, isize = partial.size(); i < isize; i++) { DateTimeField field = partial.getFieldType(i).getField(chrono); if (values[i] <= field.getMaximumValue(instant)) { instant = field.set(instant, values[i]); } } return getMaximumValue(instant); }
Example 7
Source File: MainTest.java From astor with GNU General Public License v2.0 | 4 votes |
private void testField(DateTimeField fieldA, DateTimeField fieldB, long millis, int value, long millis2) { int a, b; long x, y; boolean m, n; // get test a = fieldA.get(millis); b = fieldB.get(millis); testValue(fieldA, fieldB, "get", millis, a, b); // getMaximumValue test // Restrict this test to the fields that matter. Class fieldClass = fieldA.getClass(); if (fieldClass == TestGJDayOfYearField.class || fieldClass == TestGJDayOfMonthField.class || fieldClass == TestGJWeekOfWeekyearField.class) { a = fieldA.getMaximumValue(millis); b = fieldB.getMaximumValue(millis); testValue(fieldA, fieldB, "getMaximumValue", millis, a, b); } // set test a = getWrappedValue (value, fieldA.getMinimumValue(millis), fieldA.getMaximumValue(millis)); b = getWrappedValue (value, fieldB.getMinimumValue(millis), fieldB.getMaximumValue(millis)); if (iMode == JULIAN_MODE && a == 0 && (fieldA.getName().equals("year") || fieldA.getName().equals("weekyear"))) { // Exclude setting Julian year of zero. } else { x = fieldA.set(millis, a); y = fieldB.set(millis, b); testMillis(fieldA, fieldB, "set", millis, x, y, a, b); } // roundFloor test x = fieldA.roundFloor(millis); y = fieldB.roundFloor(millis); testMillis(fieldA, fieldB, "roundFloor", millis, x, y); // roundCeiling test x = fieldA.roundCeiling(millis); y = fieldB.roundCeiling(millis); testMillis(fieldA, fieldB, "roundCeiling", millis, x, y); // roundHalfFloor test x = fieldA.roundHalfFloor(millis); y = fieldB.roundHalfFloor(millis); testMillis(fieldA, fieldB, "roundHalfFloor", millis, x, y); // roundHalfEven test x = fieldA.roundHalfEven(millis); y = fieldB.roundHalfEven(millis); testMillis(fieldA, fieldB, "roundHalfEven", millis, x, y); // remainder test x = fieldA.remainder(millis); y = fieldB.remainder(millis); testMillis(fieldA, fieldB, "remainder", millis, x, y); // add test x = fieldA.add(millis, value); y = fieldB.add(millis, value); testMillis(fieldA, fieldB, "add", millis, x, y); // addWrapField test x = fieldA.addWrapField(millis, value); y = fieldB.addWrapField(millis, value); testMillis(fieldA, fieldB, "addWrapField", millis, x, y); // getDifference test x = fieldA.getDifference(millis, millis2); y = fieldB.getDifference(millis, millis2); try { testValue(fieldA, fieldB, "getDifference", millis, x, y); } catch (RuntimeException e) { System.out.println("Test datetime 2: " + makeDatetime(millis2)); throw e; } // isLeap test m = fieldA.isLeap(millis); n = fieldB.isLeap(millis); testBoolean(fieldA, fieldB, "isLeap", millis, m, n); // getLeapAmount test a = fieldA.getLeapAmount(millis); b = fieldB.getLeapAmount(millis); testValue(fieldA, fieldB, "getLeapAmount", millis, a, b); }
Example 8
Source File: MainTest.java From astor with GNU General Public License v2.0 | 4 votes |
private void testField(DateTimeField fieldA, DateTimeField fieldB, long millis, int value, long millis2) { int a, b; long x, y; boolean m, n; // get test a = fieldA.get(millis); b = fieldB.get(millis); testValue(fieldA, fieldB, "get", millis, a, b); // getMaximumValue test // Restrict this test to the fields that matter. Class fieldClass = fieldA.getClass(); if (fieldClass == TestGJDayOfYearField.class || fieldClass == TestGJDayOfMonthField.class || fieldClass == TestGJWeekOfWeekyearField.class) { a = fieldA.getMaximumValue(millis); b = fieldB.getMaximumValue(millis); testValue(fieldA, fieldB, "getMaximumValue", millis, a, b); } // set test a = getWrappedValue (value, fieldA.getMinimumValue(millis), fieldA.getMaximumValue(millis)); b = getWrappedValue (value, fieldB.getMinimumValue(millis), fieldB.getMaximumValue(millis)); if (iMode == JULIAN_MODE && a == 0 && (fieldA.getName().equals("year") || fieldA.getName().equals("weekyear"))) { // Exclude setting Julian year of zero. } else { x = fieldA.set(millis, a); y = fieldB.set(millis, b); testMillis(fieldA, fieldB, "set", millis, x, y, a, b); } // roundFloor test x = fieldA.roundFloor(millis); y = fieldB.roundFloor(millis); testMillis(fieldA, fieldB, "roundFloor", millis, x, y); // roundCeiling test x = fieldA.roundCeiling(millis); y = fieldB.roundCeiling(millis); testMillis(fieldA, fieldB, "roundCeiling", millis, x, y); // roundHalfFloor test x = fieldA.roundHalfFloor(millis); y = fieldB.roundHalfFloor(millis); testMillis(fieldA, fieldB, "roundHalfFloor", millis, x, y); // roundHalfEven test x = fieldA.roundHalfEven(millis); y = fieldB.roundHalfEven(millis); testMillis(fieldA, fieldB, "roundHalfEven", millis, x, y); // remainder test x = fieldA.remainder(millis); y = fieldB.remainder(millis); testMillis(fieldA, fieldB, "remainder", millis, x, y); // add test x = fieldA.add(millis, value); y = fieldB.add(millis, value); testMillis(fieldA, fieldB, "add", millis, x, y); // addWrapField test x = fieldA.addWrapField(millis, value); y = fieldB.addWrapField(millis, value); testMillis(fieldA, fieldB, "addWrapField", millis, x, y); // getDifference test x = fieldA.getDifference(millis, millis2); y = fieldB.getDifference(millis, millis2); try { testValue(fieldA, fieldB, "getDifference", millis, x, y); } catch (RuntimeException e) { System.out.println("Test datetime 2: " + makeDatetime(millis2)); throw e; } // isLeap test m = fieldA.isLeap(millis); n = fieldB.isLeap(millis); testBoolean(fieldA, fieldB, "isLeap", millis, m, n); // getLeapAmount test a = fieldA.getLeapAmount(millis); b = fieldB.getLeapAmount(millis); testValue(fieldA, fieldB, "getLeapAmount", millis, a, b); }
Example 9
Source File: BasePartial.java From astor with GNU General Public License v2.0 | 2 votes |
/** * Sets the value of the field at the specified index. * <p> * In version 2.0 and later, this method copies the array into the original. * This is because the instance variable has been changed to be final to satisfy the Java Memory Model. * This only impacts subclasses that are mutable. * * @param index the index * @param value the value to set * @throws IndexOutOfBoundsException if the index is invalid */ protected void setValue(int index, int value) { DateTimeField field = getField(index); int[] values = field.set(this, index, iValues, value); System.arraycopy(values, 0, iValues, 0, iValues.length); }
Example 10
Source File: BasePartial.java From astor with GNU General Public License v2.0 | 2 votes |
/** * Sets the value of the field at the specified index. * <p> * In version 2.0 and later, this method copies the array into the original. * This is because the instance variable has been changed to be final to satisfy the Java Memory Model. * This only impacts subclasses that are mutable. * * @param index the index * @param value the value to set * @throws IndexOutOfBoundsException if the index is invalid */ protected void setValue(int index, int value) { DateTimeField field = getField(index); int[] values = field.set(this, index, iValues, value); System.arraycopy(values, 0, iValues, 0, iValues.length); }