當前位置: 首頁>>代碼示例>>Java>>正文


Java MutableDateTime.getMillis方法代碼示例

本文整理匯總了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;
}
 
開發者ID:redfish64,項目名稱:TinyTravelTracker,代碼行數:18,代碼來源:ZoneInfoCompiler.java

示例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));
}
 
開發者ID:Talend,項目名稱:components,代碼行數:39,代碼來源:ValueConverterTest.java

示例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);
}
 
開發者ID:jaytaylor,項目名稱:sql-layer,代碼行數:6,代碼來源:MDateAndTime.java


注:本文中的org.joda.time.MutableDateTime.getMillis方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。