org.joda.time.ReadableDateTime Java Examples
The following examples show how to use
org.joda.time.ReadableDateTime.
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: FIXValue.java From philadelphia with Apache License 2.0 | 6 votes |
/** * Set the value to a time only. * * @param x a time only * @param millis if true set milliseconds, otherwise do not set milliseconds */ public void setTimeOnly(ReadableDateTime x, boolean millis) { setDigits(x.getHourOfDay(), 0, 2); bytes[2] = ':'; setDigits(x.getMinuteOfHour(), 3, 2); bytes[5] = ':'; setDigits(x.getSecondOfMinute(), 6, 2); if (millis) { bytes[8] = '.'; setDigits(x.getMillisOfSecond(), 9, 3); bytes[12] = SOH; length = 12; } else { bytes[8] = SOH; length = 8; } offset = 0; }
Example #2
Source File: FIXValue.java From philadelphia with Apache License 2.0 | 6 votes |
/** * Set the value to a timestamp. * * @param x a timestamp * @param millis if true set milliseconds, otherwise do not set milliseconds */ public void setTimestamp(ReadableDateTime x, boolean millis) { setDigits(x.getYear(), 0, 4); setDigits(x.getMonthOfYear(), 4, 2); setDigits(x.getDayOfMonth(), 6, 2); bytes[8] = '-'; setDigits(x.getHourOfDay(), 9, 2); bytes[11] = ':'; setDigits(x.getMinuteOfHour(), 12, 2); bytes[14] = ':'; setDigits(x.getSecondOfMinute(), 15, 2); if (millis) { bytes[17] = '.'; setDigits(x.getMillisOfSecond(), 18, 3); bytes[21] = SOH; length = 21; } else { bytes[17] = SOH; length = 17; } offset = 0; }
Example #3
Source File: FIXTimestamps.java From philadelphia with Apache License 2.0 | 6 votes |
/** * Append a timestamp to a string builder. * * @param t a timestamp * @param s a string builder */ public static void append(ReadableDateTime t, StringBuilder s) { char[] buffer = BUFFER.get(); setDigits(buffer, t.getYear(), 0, 4); setDigits(buffer, t.getMonthOfYear(), 4, 2); setDigits(buffer, t.getDayOfMonth(), 6, 2); buffer[8] = '-'; setDigits(buffer, t.getHourOfDay(), 9, 2); buffer[11] = ':'; setDigits(buffer, t.getMinuteOfHour(), 12, 2); buffer[14] = ':'; setDigits(buffer, t.getSecondOfMinute(), 15, 2); buffer[17] = '.'; setDigits(buffer, t.getMillisOfSecond(), 18, 3); s.append(buffer); }
Example #4
Source File: LimitChronology.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Wraps another chronology, with datetime limits. When withUTC or * withZone is called, the returned LimitChronology instance has * the same limits, except they are time zone adjusted. * * @param base base chronology to wrap * @param lowerLimit inclusive lower limit, or null if none * @param upperLimit exclusive upper limit, or null if none * @throws IllegalArgumentException if chronology is null or limits are invalid */ public static LimitChronology getInstance(Chronology base, ReadableDateTime lowerLimit, ReadableDateTime upperLimit) { if (base == null) { throw new IllegalArgumentException("Must supply a chronology"); } lowerLimit = lowerLimit == null ? null : lowerLimit.toDateTime(); upperLimit = upperLimit == null ? null : upperLimit.toDateTime(); if (lowerLimit != null && upperLimit != null) { if (!lowerLimit.isBefore(upperLimit)) { throw new IllegalArgumentException ("The lower limit must be come before than the upper limit"); } } return new LimitChronology(base, (DateTime)lowerLimit, (DateTime)upperLimit); }
Example #5
Source File: TestConverterSet.java From astor with GNU General Public License v2.0 | 6 votes |
public void testBigHashtable() { Converter[] array = new Converter[] { c1, c2, c3, c4, }; ConverterSet set = new ConverterSet(array); set.select(Boolean.class); set.select(Character.class); set.select(Byte.class); set.select(Short.class); set.select(Integer.class); set.select(Long.class); set.select(Float.class); set.select(Double.class); set.select(null); set.select(Calendar.class); set.select(GregorianCalendar.class); set.select(DateTime.class); set.select(DateMidnight.class); set.select(ReadableInstant.class); set.select(ReadableDateTime.class); set.select(ReadWritableInstant.class); // 16 set.select(ReadWritableDateTime.class); set.select(DateTime.class); assertEquals(4, set.size()); }
Example #6
Source File: LimitChronology.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Wraps another chronology, with datetime limits. When withUTC or * withZone is called, the returned LimitChronology instance has * the same limits, except they are time zone adjusted. * * @param base base chronology to wrap * @param lowerLimit inclusive lower limit, or null if none * @param upperLimit exclusive upper limit, or null if none * @throws IllegalArgumentException if chronology is null or limits are invalid */ public static LimitChronology getInstance(Chronology base, ReadableDateTime lowerLimit, ReadableDateTime upperLimit) { if (base == null) { throw new IllegalArgumentException("Must supply a chronology"); } lowerLimit = lowerLimit == null ? null : lowerLimit.toDateTime(); upperLimit = upperLimit == null ? null : upperLimit.toDateTime(); if (lowerLimit != null && upperLimit != null) { if (!lowerLimit.isBefore(upperLimit)) { throw new IllegalArgumentException ("The lower limit must be come before than the upper limit"); } } return new LimitChronology(base, (DateTime)lowerLimit, (DateTime)upperLimit); }
Example #7
Source File: TestConverterSet.java From astor with GNU General Public License v2.0 | 6 votes |
public void testBigHashtable() { Converter[] array = new Converter[] { c1, c2, c3, c4, }; ConverterSet set = new ConverterSet(array); set.select(Boolean.class); set.select(Character.class); set.select(Byte.class); set.select(Short.class); set.select(Integer.class); set.select(Long.class); set.select(Float.class); set.select(Double.class); set.select(null); set.select(Calendar.class); set.select(GregorianCalendar.class); set.select(DateTime.class); set.select(DateMidnight.class); set.select(ReadableInstant.class); set.select(ReadableDateTime.class); set.select(ReadWritableInstant.class); // 16 set.select(ReadWritableDateTime.class); set.select(DateTime.class); assertEquals(4, set.size()); }
Example #8
Source File: FIXValue.java From philadelphia with Apache License 2.0 | 5 votes |
/** * Set the value to a date. * * @param x a date */ public void setDate(ReadableDateTime x) { setDigits(x.getYear(), 0, 4); setDigits(x.getMonthOfYear(), 4, 2); setDigits(x.getDayOfMonth(), 6, 2); bytes[8] = SOH; length = 8; offset = 0; }
Example #9
Source File: ReadableInstantRelay.java From jfixture with MIT License | 5 votes |
@Override public Object create(Object request, SpecimenContext context) { if (!(request.equals(ReadableInstant.class) || request.equals(ReadWritableInstant.class) || request.equals(ReadableDateTime.class) || request.equals(ReadWritableDateTime.class))) { return new NoSpecimen(); } DateTime date = (DateTime) context.resolve(DateTime.class); return new MutableDateTime(date); }
Example #10
Source File: Row.java From beam with Apache License 2.0 | 4 votes |
/** * Get a {@link TypeName#DATETIME} value by field name, {@link IllegalStateException} is thrown if * schema doesn't match. */ @Nullable public ReadableDateTime getDateTime(String fieldName) { return getDateTime(getSchema().indexOf(fieldName)); }
Example #11
Source File: Row.java From beam with Apache License 2.0 | 4 votes |
/** * Get a {@link TypeName#DATETIME} value by field index, {@link IllegalStateException} is thrown * if schema doesn't match. */ @Nullable public ReadableDateTime getDateTime(int idx) { ReadableInstant instant = getValue(idx); return instant == null ? null : new DateTime(instant).withZone(instant.getZone()); }
Example #12
Source File: TestAllInterfaceDataTypesAreSupported.java From jfixture with MIT License | 4 votes |
@Test public void creates_instance_of_ReadableDateTime() { ReadableDateTime dateTime = fixture.create(ReadableDateTime.class); assertThat(dateTime, notNullValue()); assertThat(new Date(dateTime.getMillis()), is(date)); }