本文整理汇总了Java中org.joda.time.ReadableDateTime类的典型用法代码示例。如果您正苦于以下问题:Java ReadableDateTime类的具体用法?Java ReadableDateTime怎么用?Java ReadableDateTime使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReadableDateTime类属于org.joda.time包,在下文中一共展示了ReadableDateTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AggregateKeyGenerator
import org.joda.time.ReadableDateTime; //导入依赖的package包/类
public AggregateKeyGenerator(String repoPrefix, String counterName, ReadableDateTime dateTime) {
Assert.notNull(counterName, "Counter name name can not be null");
Assert.notNull(dateTime, "DateTime can not be null");
this.repoPrefix = repoPrefix;
this.counterName = counterName;
String timeStamp = dateTimeFormatter.print(dateTime);
totalKey = key("total");
hourKey = key(timeStamp.substring(0, 10));
dayKey = key(timeStamp.substring(0, 8));
monthKey = key(timeStamp.substring(0, 6));
yearKey = key(timeStamp.substring(0, 4));
yearsKey = key("years");
minute = timeStamp.substring(10, 12);
hour = timeStamp.substring(8, 10);
day = timeStamp.substring(6, 8);
month = timeStamp.substring(4, 6);
year = timeStamp.substring(0, 4);
}
示例2: setTimeOnly
import org.joda.time.ReadableDateTime; //导入依赖的package包/类
/**
* Set the value to a time only.
*
* @param t a time only
* @param millis if true set milliseconds, otherwise do not set milliseconds
*/
public void setTimeOnly(ReadableDateTime t, boolean millis) {
setDigits(t.getHourOfDay(), 2, 0);
bytes[2] = ':';
setDigits(t.getMinuteOfHour(), 2, 3);
bytes[5] = ':';
setDigits(t.getSecondOfMinute(), 2, 6);
if (millis) {
bytes[8] = '.';
setDigits(t.getMillisOfSecond(), 3, 9);
bytes[12] = SOH;
length = 12;
} else {
bytes[8] = SOH;
length = 8;
}
offset = 0;
}
示例3: setTimestamp
import org.joda.time.ReadableDateTime; //导入依赖的package包/类
/**
* Set the value to a timestamp.
*
* @param t a timestamp
* @param millis if true set milliseconds, otherwise do not set milliseconds
*/
public void setTimestamp(ReadableDateTime t, boolean millis) {
setDigits(t.getYear(), 4, 0);
setDigits(t.getMonthOfYear(), 2, 4);
setDigits(t.getDayOfMonth(), 2, 6);
bytes[8] = '-';
setDigits(t.getHourOfDay(), 2, 9);
bytes[11] = ':';
setDigits(t.getMinuteOfHour(), 2, 12);
bytes[14] = ':';
setDigits(t.getSecondOfMinute(), 2, 15);
if (millis) {
bytes[17] = '.';
setDigits(t.getMillisOfSecond(), 3, 18);
bytes[21] = SOH;
length = 21;
} else {
bytes[17] = SOH;
length = 17;
}
offset = 0;
}
示例4: getInstance
import org.joda.time.ReadableDateTime; //导入依赖的package包/类
/**
* 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: testBigHashtable
import org.joda.time.ReadableDateTime; //导入依赖的package包/类
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: deserialize
import org.joda.time.ReadableDateTime; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public ReadableDateTime deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException
{
JsonToken t = jp.getCurrentToken();
if (t == JsonToken.VALUE_STRING) {
String str = jp.getText().trim();
if (str.length() == 0) { // [JACKSON-360]
return null;
}
// always use the tz in the string
return ISODateTimeFormat.dateTime().withOffsetParsed().parseDateTime(str);
}
// TODO: in 2.4, use 'handledType()'
throw ctxt.mappingException(getValueClass());
}
示例7: parseDeparture
import org.joda.time.ReadableDateTime; //导入依赖的package包/类
private Departure parseDeparture(Attributes attributes, ReadableDateTime time) {
Departure.Builder departure = Departure.newBuilder();
departure.setName(attributes.getValue(XML_DEPARTURE_NAME));
// As no time zone is given, assume the one from the parameter
String xmlDate = attributes.getValue(XML_DEPARTURE_DATE);
String xmlTime = attributes.getValue(XML_DEPARTURE_TIME);
LocalDateTime localTime = DATE_TIME_FORMATTER.parseLocalDateTime(xmlDate + xmlTime);
departure.setTime(localTime.toDateTime(time.getZone()));
String xmlDirection = attributes.getValue(XML_DEPARTURE_DIRECTION);
if (xmlDirection != null) {
departure.setDirection(xmlDirection);
}
return departure.build();
}
示例8: DateObjectValueSource
import org.joda.time.ReadableDateTime; //导入依赖的package包/类
DateObjectValueSource(IndexFieldData<?> indexFieldData, MultiValueMode multiValueMode,
String methodName, ToIntFunction<ReadableDateTime> function) {
super(indexFieldData, multiValueMode);
Objects.requireNonNull(methodName);
this.methodName = methodName;
this.function = function;
}
示例9: getDate
import org.joda.time.ReadableDateTime; //导入依赖的package包/类
@Deprecated
public ReadableDateTime getDate() {
deprecationLogger.deprecated("getDate on numeric fields is deprecated. Use a date field to get dates.");
if (dates == null) {
dates = new Dates(values);
dates.refreshArray();
}
return dates.getValue();
}
示例10: getDates
import org.joda.time.ReadableDateTime; //导入依赖的package包/类
@Deprecated
public List<ReadableDateTime> getDates() {
deprecationLogger.deprecated("getDates on numeric fields is deprecated. Use a date field to get dates.");
if (dates == null) {
dates = new Dates(values);
dates.refreshArray();
}
return dates;
}
示例11: getValue
import org.joda.time.ReadableDateTime; //导入依赖的package包/类
/**
* Fetch the first field value or 0 millis after epoch if there are no values.
*/
public ReadableDateTime getValue() {
if (values.count() == 0) {
return EPOCH;
}
return get(0);
}
示例12: get
import org.joda.time.ReadableDateTime; //导入依赖的package包/类
@Override
public ReadableDateTime get(int index) {
if (index >= values.count()) {
throw new IndexOutOfBoundsException(
"attempted to fetch the [" + index + "] date when there are only [" + values.count() + "] dates.");
}
return dates[index];
}
示例13: setDate
import org.joda.time.ReadableDateTime; //导入依赖的package包/类
/**
* Set the value to a date.
*
* @param d a date
*/
public void setDate(ReadableDateTime d) {
setDigits(d.getYear(), 4, 0);
setDigits(d.getMonthOfYear(), 2, 4);
setDigits(d.getDayOfMonth(), 2, 6);
bytes[8] = SOH;
length = 8;
offset = 0;
}
示例14: append
import org.joda.time.ReadableDateTime; //导入依赖的package包/类
/**
* Append a timestamp to a string builder.
*
* @param t a timestamp
* @param s a string builder
*/
public static void append(ReadableDateTime t, StringBuilder s) {
s.append(t.getYear());
appendTwoDigits(t.getMonthOfYear(), s);
appendTwoDigits(t.getDayOfMonth(), s);
s.append('-');
appendTwoDigits(t.getHourOfDay(), s);
s.append(':');
appendTwoDigits(t.getMinuteOfHour(), s);
s.append(':');
appendTwoDigits(t.getSecondOfMinute(), s);
s.append('.');
appendThreeDigits(t.getMillisOfSecond(), s);
}
示例15: valueOf
import org.joda.time.ReadableDateTime; //导入依赖的package包/类
public static FDate valueOf(final ReadableDateTime jodaTime) {
if (jodaTime != null) {
return new FDate(jodaTime);
} else {
return null;
}
}