本文整理匯總了Java中org.joda.time.MutableDateTime.getMillis方法的典型用法代碼示例。如果您正苦於以下問題:Java MutableDateTime.getMillis方法的具體用法?Java MutableDateTime.getMillis怎麽用?Java MutableDateTime.getMillis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.joda.time.MutableDateTime
的用法示例。
在下文中一共展示了MutableDateTime.getMillis方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseTime
import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
static int parseTime(String str) {
DateTimeFormatter p = ISODateTimeFormat.hourMinuteSecondFraction();
MutableDateTime mdt = new MutableDateTime(0, getLenientISOChronology());
int pos = 0;
if (str.startsWith("-")) {
pos = 1;
}
int newPos = p.parseInto(mdt, str, pos);
if (newPos == ~pos) {
throw new IllegalArgumentException(str);
}
int millis = (int)mdt.getMillis();
if (pos == 1) {
millis = -millis;
}
return millis;
}
示例2: testXMLGregorianCalendarConverter
import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
@Test
public void testXMLGregorianCalendarConverter() throws Exception {
DateTimeZone tz1 = DateTimeZone.getDefault();
MutableDateTime dateTime1 = new MutableDateTime(tz1);
dateTime1.setDate(System.currentTimeMillis());
Long controlValue1 = dateTime1.getMillis();
XMLGregorianCalendar xmlCalendar1 = datatypeFactory.newXMLGregorianCalendar();
xmlCalendar1.setYear(dateTime1.getYear());
xmlCalendar1.setMonth(dateTime1.getMonthOfYear());
xmlCalendar1.setDay(dateTime1.getDayOfMonth());
xmlCalendar1.setHour(dateTime1.getHourOfDay());
xmlCalendar1.setMinute(dateTime1.getMinuteOfHour());
xmlCalendar1.setSecond(dateTime1.getSecondOfMinute());
xmlCalendar1.setMillisecond(dateTime1.getMillisOfSecond());
xmlCalendar1.setTimezone(tz1.toTimeZone().getOffset(dateTime1.getMillis()) / 60000);
FieldDesc fieldInfo = typeDesc.getField("tranDate");
NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName());
AvroConverter<XMLGregorianCalendar, Long> converter1 =
(AvroConverter<XMLGregorianCalendar, Long>) transducer.getValueConverter(fieldInfo);
assertEquals(AvroUtils._logicalTimestamp(), converter1.getSchema());
assertEquals(XMLGregorianCalendar.class, converter1.getDatumClass());
assertEquals(controlValue1,
converter1.convertToAvro(xmlCalendar1));
assertEquals(xmlCalendar1,
converter1.convertToDatum(controlValue1));
AvroConverter<XMLGregorianCalendar, Object> converter2 =
(AvroConverter<XMLGregorianCalendar, Object>) transducer.getValueConverter(fieldInfo);
assertEquals(xmlCalendar1,
converter2.convertToDatum(new Date(controlValue1.longValue())));
assertNull(converter1.convertToAvro(null));
}
示例3: getTimestamp
import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
/** Encode {@code dt} as a MySQL internal TIMESTAMP. Range is unchecked. */
public static int getTimestamp(long[] dt, String tz) {
MutableDateTime dateTime = toJodaDateTime(dt, tz);
return (int)(dateTime.getMillis() / 1000L);
}