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

x33g5p2x  于2022-01-20 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(152)

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

Instant.toDateTime介绍

[英]Get this object as a DateTime using ISOChronology in the default zone.

This method returns a DateTime object in the default zone. This differs from the similarly named method on DateTime, DateMidnight or MutableDateTime which retains the time zone. The difference is because Instant really represents a time without a zone, thus calling this method we really have no zone to 'retain' and hence expect to switch to the default zone.

This method definition preserves compatibility with earlier versions of Joda-Time.
[中]使用默认区域中的等时方法获取此对象作为日期时间。
此方法返回默认区域中的DateTime对象。这与保留时区的DateTime、DateMidnight或MutableDateTime上类似命名的方法不同。区别在于Instant实际上表示一个没有区域的时间,因此调用此方法时,我们实际上没有要“保留”的区域,因此希望切换到默认区域。
此方法定义保留了与Joda Time早期版本的兼容性。

代码示例

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

/**
 * Get this object as a DateTime using ISOChronology in the default zone.
 * This method is identical to <code>toDateTime()</code>.
 * <p>
 * This method returns a DateTime object in the default zone.
 * This differs from the similarly named method on DateTime, DateMidnight
 * or MutableDateTime which retains the time zone. The difference is
 * because Instant really represents a time <i>without</i> a zone,
 * thus calling this method we really have no zone to 'retain' and
 * hence expect to switch to the default zone.
 * <p>
 * This method is deprecated because it is a duplicate of {@link #toDateTime()}.
 * However, removing it would cause the superclass implementation to be used,
 * which would create silent bugs in any caller depending on this implementation.
 * As such, the method itself is not currently planned to be removed.
 * <p>
 * This method definition preserves compatibility with earlier versions
 * of Joda-Time.
 *
 * @return a DateTime using the same millis with ISOChronology
 * @deprecated Use toDateTime() as it is identical
 */
@Deprecated
public DateTime toDateTimeISO() {
  return toDateTime();
}

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

/**
 * Get this object as a DateTime using ISOChronology in the default zone.
 * This method is identical to <code>toDateTime()</code>.
 * <p>
 * This method returns a DateTime object in the default zone.
 * This differs from the similarly named method on DateTime, DateMidnight
 * or MutableDateTime which retains the time zone. The difference is
 * because Instant really represents a time <i>without</i> a zone,
 * thus calling this method we really have no zone to 'retain' and
 * hence expect to switch to the default zone.
 * <p>
 * This method is deprecated because it is a duplicate of {@link #toDateTime()}.
 * However, removing it would cause the superclass implementation to be used,
 * which would create silent bugs in any caller depending on this implementation.
 * As such, the method itself is not currently planned to be removed.
 * <p>
 * This method definition preserves compatibility with earlier versions
 * of Joda-Time.
 *
 * @return a DateTime using the same millis with ISOChronology
 * @deprecated Use toDateTime() as it is identical
 */
@Deprecated
public DateTime toDateTimeISO() {
  return toDateTime();
}

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

/**
 * Get this object as a DateTime using ISOChronology in the default zone.
 * This method is identical to <code>toDateTime()</code>.
 * <p>
 * This method returns a DateTime object in the default zone.
 * This differs from the similarly named method on DateTime, DateMidnight
 * or MutableDateTime which retains the time zone. The difference is
 * because Instant really represents a time <i>without</i> a zone,
 * thus calling this method we really have no zone to 'retain' and
 * hence expect to switch to the default zone.
 * <p>
 * This method is deprecated because it is a duplicate of {@link #toDateTime()}.
 * However, removing it would cause the superclass implementation to be used,
 * which would create silent bugs in any caller depending on this implementation.
 * As such, the method itself is not currently planned to be removed.
 * <p>
 * This method definition preserves compatibility with earlier versions
 * of Joda-Time.
 *
 * @return a DateTime using the same millis with ISOChronology
 * @deprecated Use toDateTime() as it is identical
 */
@Deprecated
public DateTime toDateTimeISO() {
  return toDateTime();
}

代码示例来源:origin: Teradata/kylo

public DateTime fromNonNullString(String s) {
  return new Instant(s).toDateTime(DateTimeZone.UTC);
}

代码示例来源:origin: Teradata/kylo

public DateTime fromNonNullValue(Long value) {
  return new Instant(value).toDateTime(DateTimeZone.UTC);
}

代码示例来源:origin: org.n52.arctic-sea/shetland

/**
 * Creates a new {@code TimeInstant}.
 *
 * @param instant the instant
 */
public TimeInstant(Instant instant) {
  this(instant != null ? instant.toDateTime() : null, 0, null);
}

代码示例来源:origin: stackoverflow.com

Instant instant = Instant.now();
DateTimeZone zone = DateTimeZone.getDefault();
LocalDate date = instant.toDateTime(zone).toLocalDate();

代码示例来源:origin: stackoverflow.com

/**
* Zone to use for input and output
*/
private static final DateTimeZone ZONE = DateTimeZone.forId("Europe/London");

/**
 * Adds a number of days specified to the instant in time specified.
 *
 * @param instant - the date to be added to
 * @param numberOfDaysToAdd - the number of days to be added to the instant specified
 * @return an instant that has been incremented by the number of days specified
 */
public static Instant addNumberOfDaysToInstant(final Instant instant, final int numberOfDaysToAdd) {
  return instant.toDateTime(ZONE).withFieldAdded(DurationFieldType.days(), numberOfDaysToAdd).toInstant();
}

代码示例来源:origin: outbrain/Aletheia

@Override
 public DateTime extractDatumDateTime(final Breadcrumb domainObject) {
  return domainObject.getProcessingTimestamp().toDateTime();
 }
}

代码示例来源:origin: outbrain/Aletheia

@Override
 public DateTime extractDatumDateTime(final MyDatum domainObject) {
  return domainObject.getTimestamp().toDateTime();
 }
}

代码示例来源:origin: outbrain/Aletheia

@Override
 public DateTime extractDatumDateTime(final MyDatum domainObject) {
  return domainObject.getTimestamp().toDateTime();
 }
}

代码示例来源:origin: com.thinkbiganalytics.kylo/kylo-commons-jpa

public DateTime fromNonNullValue(Long value) {
  return new Instant(value).toDateTime(DateTimeZone.UTC);
}

代码示例来源:origin: com.thinkbiganalytics.kylo/kylo-commons-jpa

public DateTime fromNonNullString(String s) {
  return new Instant(s).toDateTime(DateTimeZone.UTC);
}

代码示例来源:origin: stackoverflow.com

// 1 month 5d 22h 35m 39s
Period period = new Period(0, 1, 0, 5, 22, 35, 39, 0);

Instant start = new Instant();
// current time => 2011-03-17T22:24:01.848+01:00
Duration dura = new Duration(start, start.toDateTime().plus(period));
Period period2 = new Period(dura).normalizedStandard(PeriodType.dayTime());
// => 36d 21h 35m 39s

代码示例来源:origin: com.google.api-ads/ads-lib

/**
 * Converts an {@code Instant} object to an API date time in the time zone
 * supplied.
 */
public T toDateTime(Instant instant, String timeZoneId) {
 return toDateTime(
   instant.toDateTime(DateTimeZone.forTimeZone(TimeZone.getTimeZone(timeZoneId))));
}

代码示例来源:origin: googleads/googleads-java-lib

/**
 * Converts an {@code Instant} object to an API date time in the time zone
 * supplied.
 */
public T toDateTime(Instant instant, String timeZoneId) {
 return toDateTime(
   instant.toDateTime(DateTimeZone.forTimeZone(TimeZone.getTimeZone(timeZoneId))));
}

代码示例来源:origin: outbrain/Aletheia

@Override
 public DateTime extractDatumDateTime(final SampleDomainClass domainObject) {
  return domainObject.getEventTimestamp().toDateTime();
 }
}

代码示例来源:origin: powertac/powertac-server

protected Instant startOfDay ()
{
 Instant start = service.getTimeslotRepo().currentTimeslot().getStartInstant();
 return start.toDateTime(DateTimeZone.UTC).withHourOfDay(0).toInstant();
}

代码示例来源:origin: powertac/powertac-server

protected Instant lastSunday ()
{
 Instant start = service.getTimeslotRepo().currentTimeslot().getStartInstant();
 return start.toDateTime(DateTimeZone.UTC)
   .withDayOfWeek(1).withHourOfDay(0).toInstant();
}

代码示例来源:origin: powertac/powertac-server

protected Instant nextStartOfDay ()
{
 Instant start = service.getTimeslotRepo().currentTimeslot().getStartInstant();
 return start.toDateTime(DateTimeZone.UTC)
   .withHourOfDay(0).toInstant().plus(TimeService.DAY);
}

相关文章