类org.joda.time.ReadableDateTime源码实例Demo

下面列出了怎么用org.joda.time.ReadableDateTime的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: philadelphia   文件: FIXValue.java
/**
 * 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;
}
 
源代码2 项目: philadelphia   文件: FIXValue.java
/**
 * 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;
}
 
源代码3 项目: philadelphia   文件: FIXTimestamps.java
/**
 * 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);
}
 
源代码4 项目: astor   文件: LimitChronology.java
/**
 * 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);
}
 
源代码5 项目: astor   文件: TestConverterSet.java
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());
}
 
源代码6 项目: astor   文件: LimitChronology.java
/**
 * 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);
}
 
源代码7 项目: astor   文件: TestConverterSet.java
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());
}
 
源代码8 项目: philadelphia   文件: FIXValue.java
/**
 * 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;
}
 
源代码9 项目: jfixture   文件: ReadableInstantRelay.java
@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);
}
 
源代码10 项目: beam   文件: Row.java
/**
 * 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));
}
 
源代码11 项目: beam   文件: Row.java
/**
 * 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());
}
 
@Test
public void creates_instance_of_ReadableDateTime() {
    ReadableDateTime dateTime = fixture.create(ReadableDateTime.class);
    assertThat(dateTime, notNullValue());
    assertThat(new Date(dateTime.getMillis()), is(date));
}
 
 类所在包
 类方法
 同包方法