org.joda.time.LocalDateTime.getMillisOfSecond()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(12.2k)|赞(0)|评价(0)|浏览(165)

本文整理了Java中org.joda.time.LocalDateTime.getMillisOfSecond()方法的一些代码示例,展示了LocalDateTime.getMillisOfSecond()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDateTime.getMillisOfSecond()方法的具体详情如下:
包路径:org.joda.time.LocalDateTime
类名称:LocalDateTime
方法名:getMillisOfSecond

LocalDateTime.getMillisOfSecond介绍

[英]Get the millis of second field value.
[中]获取毫秒字段值。

代码示例

代码示例来源:origin: joda-time/joda-time

/**
 * Get the date time as a <code>java.util.Date</code> using the specified time zone.
 * <p>
 * The <code>Date</code> object created has exactly the same fields as this
 * date-time, except when the time would be invalid due to a daylight savings
 * gap. In that case, the time will be set to the earliest valid time after the gap.
 * <p>
 * In the case of a daylight savings overlap, the earlier instant is selected.
 * <p>
 * Converting to a JDK Date is full of complications as the JDK Date constructor
 * doesn't behave as you might expect around DST transitions. This method works
 * by taking a first guess and then adjusting. This also handles the situation
 * where the JDK time zone data differs from the Joda-Time time zone data.
 * <p>
 * Unlike {@link #toDate()}, this implementation does not rely on Java's synchronized
 * time zone initialization logic, and should demonstrate better concurrent performance
 * characteristics.
 *
 * @return a Date initialised with this date-time, never null
 * @since 2.3
 */
public Date toDate(final TimeZone timeZone) {
  final Calendar calendar = Calendar.getInstance(timeZone);
  calendar.clear();
  calendar.set(getYear(), getMonthOfYear() - 1, getDayOfMonth(),
        getHourOfDay(), getMinuteOfHour(), getSecondOfMinute());
  Date date = calendar.getTime();
  date.setTime(date.getTime() + getMillisOfSecond());
  return correctDstTransition(date, timeZone);
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Get the date time as a <code>java.util.Date</code> using the specified time zone.
 * <p>
 * The <code>Date</code> object created has exactly the same fields as this
 * date-time, except when the time would be invalid due to a daylight savings
 * gap. In that case, the time will be set to the earliest valid time after the gap.
 * <p>
 * In the case of a daylight savings overlap, the earlier instant is selected.
 * <p>
 * Converting to a JDK Date is full of complications as the JDK Date constructor
 * doesn't behave as you might expect around DST transitions. This method works
 * by taking a first guess and then adjusting. This also handles the situation
 * where the JDK time zone data differs from the Joda-Time time zone data.
 * <p>
 * Unlike {@link #toDate()}, this implementation does not rely on Java's synchronized
 * time zone initialization logic, and should demonstrate better concurrent performance
 * characteristics.
 *
 * @return a Date initialised with this date-time, never null
 * @since 2.3
 */
public Date toDate(final TimeZone timeZone) {
  final Calendar calendar = Calendar.getInstance(timeZone);
  calendar.clear();
  calendar.set(getYear(), getMonthOfYear() - 1, getDayOfMonth(),
        getHourOfDay(), getMinuteOfHour(), getSecondOfMinute());
  Date date = calendar.getTime();
  date.setTime(date.getTime() + getMillisOfSecond());
  return correctDstTransition(date, timeZone);
}

代码示例来源:origin: joda-time/joda-time

/**
 * Get the date time as a <code>java.util.Date</code>.
 * <p>
 * The <code>Date</code> object created has exactly the same fields as this
 * date-time, except when the time would be invalid due to a daylight savings
 * gap. In that case, the time will be set to the earliest valid time after the gap.
 * <p>
 * In the case of a daylight savings overlap, the earlier instant is selected.
 * <p>
 * Converting to a JDK Date is full of complications as the JDK Date constructor
 * doesn't behave as you might expect around DST transitions. This method works
 * by taking a first guess and then adjusting. This also handles the situation
 * where the JDK time zone data differs from the Joda-Time time zone data.
 *
 * @return a Date initialised with this date-time, never null
 * @since 2.0
 */
@SuppressWarnings("deprecation")
public Date toDate() {
  int dom = getDayOfMonth();
  Date date = new Date(getYear() - 1900, getMonthOfYear() - 1, dom,
          getHourOfDay(), getMinuteOfHour(), getSecondOfMinute());
  date.setTime(date.getTime() + getMillisOfSecond());
  return correctDstTransition(date, TimeZone.getDefault());
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Get the date time as a <code>java.util.Date</code>.
 * <p>
 * The <code>Date</code> object created has exactly the same fields as this
 * date-time, except when the time would be invalid due to a daylight savings
 * gap. In that case, the time will be set to the earliest valid time after the gap.
 * <p>
 * In the case of a daylight savings overlap, the earlier instant is selected.
 * <p>
 * Converting to a JDK Date is full of complications as the JDK Date constructor
 * doesn't behave as you might expect around DST transitions. This method works
 * by taking a first guess and then adjusting. This also handles the situation
 * where the JDK time zone data differs from the Joda-Time time zone data.
 *
 * @return a Date initialised with this date-time, never null
 * @since 2.0
 */
@SuppressWarnings("deprecation")
public Date toDate() {
  int dom = getDayOfMonth();
  Date date = new Date(getYear() - 1900, getMonthOfYear() - 1, dom,
          getHourOfDay(), getMinuteOfHour(), getSecondOfMinute());
  date.setTime(date.getTime() + getMillisOfSecond());
  return correctDstTransition(date, TimeZone.getDefault());
}

代码示例来源:origin: joda-time/joda-time

/**
 * Converts this object to a DateTime using the specified zone.
 * <p>
 * When the time zone is applied, the local date-time may be affected by daylight saving.
 * In a daylight saving gap, when the local time does not exist,
 * this method will throw an exception.
 * In a daylight saving overlap, when the same local time occurs twice,
 * this method returns the first occurrence of the local time.
 * 
 * @param zone time zone to apply, or default if null
 * @return a DateTime using the same millis
 * @throws IllegalInstantException if the local time does not exist when the time zone is applied
 */
public DateTime toDateTime(DateTimeZone zone) {
  zone = DateTimeUtils.getZone(zone);
  Chronology chrono = iChronology.withZone(zone);
  return new DateTime(
      getYear(), getMonthOfYear(), getDayOfMonth(),
      getHourOfDay(), getMinuteOfHour(),
      getSecondOfMinute(), getMillisOfSecond(), chrono);
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Converts this object to a DateTime using the specified zone.
 * <p>
 * When the time zone is applied, the local date-time may be affected by daylight saving.
 * In a daylight saving gap, when the local time does not exist,
 * this method will throw an exception.
 * In a daylight saving overlap, when the same local time occurs twice,
 * this method returns the first occurrence of the local time.
 * 
 * @param zone time zone to apply, or default if null
 * @return a DateTime using the same millis
 * @throws IllegalInstantException if the local time does not exist when the time zone is applied
 */
public DateTime toDateTime(DateTimeZone zone) {
  zone = DateTimeUtils.getZone(zone);
  Chronology chrono = iChronology.withZone(zone);
  return new DateTime(
      getYear(), getMonthOfYear(), getDayOfMonth(),
      getHourOfDay(), getMinuteOfHour(),
      getSecondOfMinute(), getMillisOfSecond(), chrono);
}

代码示例来源:origin: alibaba/fastjson

format = formatter_iso8601_pattern;
} else {
  int millis = dateTime.getMillisOfSecond();
  if (millis == 0) {
    format = formatter_iso8601_pattern_23;

代码示例来源:origin: com.alibaba/fastjson

format = formatter_iso8601_pattern;
} else {
  int millis = dateTime.getMillisOfSecond();
  if (millis == 0) {
    format = formatter_iso8601_pattern_23;

代码示例来源:origin: camunda/camunda-bpm-platform

Date date = new Date(getYear() - 1900, getMonthOfYear() - 1, dom,
        getHourOfDay(), getMinuteOfHour(), getSecondOfMinute());
date.setTime(date.getTime() + getMillisOfSecond());
LocalDateTime check = LocalDateTime.fromDateFields(date);
if (check.isBefore(this)) {

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Converts this object to a DateTime using the specified zone.
 * <p>
 * This method will throw an exception if the datetime that would be
 * created does not exist when the time zone is taken into account.
 * 
 * @param zone time zone to apply, or default if null
 * @return a DateTime using the same millis
 */
public DateTime toDateTime(DateTimeZone zone) {
  zone = DateTimeUtils.getZone(zone);
  Chronology chrono = iChronology.withZone(zone);
  return new DateTime(
      getYear(), getMonthOfYear(), getDayOfMonth(),
      getHourOfDay(), getMinuteOfHour(),
      getSecondOfMinute(), getMillisOfSecond(), chrono);
}

代码示例来源:origin: dremio/dremio-oss

public TimePrintMillis(LocalDateTime time) {
 super(time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute());
 millisOfSecond = time.getMillisOfSecond();
}

代码示例来源:origin: org.sonatype.sisu/sisu-odata4j

public static String formatDateTimeForXml(LocalDateTime localDateTime) {
 if (localDateTime == null)
  return null;
 if (localDateTime.getMillisOfSecond() != 0)
  return localDateTime.toString(DATETIME_WITH_MILLIS_XML);
 else if (localDateTime.getSecondOfMinute() != 0)
  return localDateTime.toString(DATETIME_WITH_SECONDS_XML);
 else
  return localDateTime.toString(DATETIME_XML);
}

代码示例来源:origin: org.jboss.oreva/odata-core

public static String formatDateTimeForXml(LocalDateTime localDateTime) {
 if (localDateTime == null)
  return null;
 if (localDateTime.getMillisOfSecond() != 0)
  return localDateTime.toString(DATETIME_WITH_MILLIS_XML);
 else if (localDateTime.getSecondOfMinute() != 0)
  return localDateTime.toString(DATETIME_WITH_SECONDS_XML);
 else
  return localDateTime.toString(DATETIME_XML);
}

代码示例来源:origin: odata4j/odata4j

public static String formatDateTimeForXml(LocalDateTime localDateTime) {
 if (localDateTime == null)
  return null;
 if (localDateTime.getMillisOfSecond() != 0)
  return localDateTime.toString(DATETIME_WITH_MILLIS_XML);
 else if (localDateTime.getSecondOfMinute() != 0)
  return localDateTime.toString(DATETIME_WITH_SECONDS_XML);
 else
  return localDateTime.toString(DATETIME_XML);
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
  public java.time.LocalDateTime convert(LocalDateTime in, Context context) throws Exception {
    if (in == null) return null;
    return java.time.LocalDateTime.of(in.getYear(), in.getMonthOfYear(), in.getDayOfMonth(), in.getHourOfDay(), in.getMinuteOfHour(), in.getSecondOfMinute(), in.getMillisOfSecond() * 1000);
  }
}

代码示例来源:origin: dremio/dremio-oss

@Override
public void setup() {
  int timeZoneIndex = contextInfo.getRootFragmentTimeZone();
  org.joda.time.DateTimeZone timeZone = org.joda.time.DateTimeZone.forID(org.apache.arrow.vector.util.DateUtility.getTimeZone(timeZoneIndex));
  org.joda.time.LocalDateTime now = new org.joda.time.LocalDateTime(contextInfo.getQueryStartTime(), timeZone);
  queryStartTime= (now.getHourOfDay() * org.apache.arrow.vector.util.DateUtility.hoursToMillis) +
              (now.getMinuteOfHour() * org.apache.arrow.vector.util.DateUtility.minutesToMillis) +
              (now.getSecondOfMinute() * org.apache.arrow.vector.util.DateUtility.secondsToMillis) +
              (now.getMillisOfSecond());
}

代码示例来源:origin: dremio/dremio-oss

@Override
public void setup() {
  org.joda.time.LocalDateTime now = new org.joda.time.LocalDateTime(contextInfo.getQueryStartTime(), org.joda.time.DateTimeZone.UTC);
  queryStartTime= (now.getHourOfDay() * org.apache.arrow.vector.util.DateUtility.hoursToMillis) +
              (now.getMinuteOfHour() * org.apache.arrow.vector.util.DateUtility.minutesToMillis) +
              (now.getSecondOfMinute() * org.apache.arrow.vector.util.DateUtility.secondsToMillis) +
              (now.getMillisOfSecond());
}

代码示例来源:origin: dremio/dremio-oss

@Override
public Timestamp getTimestamp(int index) {
 if (ac.isNull(index)) {
  return null;
 }
 org.joda.time.LocalDateTime date = new org.joda.time.LocalDateTime(ac.get(index), org.joda.time.DateTimeZone.UTC);
 return new Timestamp(date.getYear() - 1900,
            date.getMonthOfYear() - 1,
            date.getDayOfMonth(),
            date.getHourOfDay(),
            date.getMinuteOfHour(),
            date.getSecondOfMinute(),
            (int) java.util.concurrent.TimeUnit.MILLISECONDS.toNanos(date.getMillisOfSecond()));
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * Converts this object to a DateTime using the specified zone.
 * <p>
 * This method will throw an exception if the datetime that would be
 * created does not exist when the time zone is taken into account.
 * 
 * @param zone time zone to apply, or default if null
 * @return a DateTime using the same millis
 */
public DateTime toDateTime(DateTimeZone zone) {
  zone = DateTimeUtils.getZone(zone);
  Chronology chrono = iChronology.withZone(zone);
  return new DateTime(
      getYear(), getMonthOfYear(), getDayOfMonth(),
      getHourOfDay(), getMinuteOfHour(),
      getSecondOfMinute(), getMillisOfSecond(), chrono);
}

代码示例来源:origin: dremio/dremio-oss

@Override
 public RexNode convertCall(SqlRexContext cx, SqlCall call) {
  final int timeZoneIndex = getContextInformation().getRootFragmentTimeZone();
  final DateTimeZone timeZone = DateTimeZone.forID(DateUtility.getTimeZone(timeZoneIndex));
  final LocalDateTime dateTime = new LocalDateTime(getContextInformation().getQueryStartTime(), timeZone);
  final long queryStartTime =
    (dateTime.getHourOfDay() * DateUtility.hoursToMillis) +
      (dateTime.getMinuteOfHour() * DateUtility.minutesToMillis) +
      (dateTime.getSecondOfMinute() * DateUtility.secondsToMillis) +
      (dateTime.getMillisOfSecond());
  return cx.getRexBuilder()
    .makeTimeLiteral(
      DateTimes.toDateTime(new LocalDateTime(queryStartTime, DateTimeZone.UTC))
        .toCalendar(null), // null sets locale to default locale
      getReturnTypePrecision(cx, call));
 }
}

相关文章