本文整理了Java中org.joda.time.LocalDateTime.correctDstTransition()
方法的一些代码示例,展示了LocalDateTime.correctDstTransition()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDateTime.correctDstTransition()
方法的具体详情如下:
包路径:org.joda.time.LocalDateTime
类名称:LocalDateTime
方法名:correctDstTransition
[英]Correct date
in case of DST overlap.
The Date
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.
In the case of a daylight savings overlap, the earlier instant is selected.
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.
[中]如果DST重叠,请更正date
。
创建的Date
对象具有与此日期时间完全相同的字段,除非该时间因夏令时间隔而无效。在这种情况下,时间将设置为间隔后最早的有效时间。
在夏令时重叠的情况下,选择较早的瞬间。
转换为JDK日期充满了复杂性,因为JDK日期构造函数在DST转换前后的行为可能与您预期的不同。这种方法的工作原理是先猜测,然后调整。这还可以处理JDK时区数据与Joda时区数据不同的情况。
代码示例来源: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> 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: org.apache.servicemix.bundles/org.apache.servicemix.bundles.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: com.ning.billing/killbill-osgi-bundles-analytics
/**
* 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: io.virtdata/virtdata-lib-realer
/**
* 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: Nextdoor/bender
/**
* 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: com.ning.billing/killbill-osgi-bundles-jruby
/**
* 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: org.kill-bill.billing/killbill-osgi-bundles-jruby
/**
* 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: io.virtdata/virtdata-lib-realer
/**
* 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: org.kill-bill.billing/killbill-osgi-bundles-jruby
/**
* 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: Nextdoor/bender
/**
* 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: org.apache.servicemix.bundles/org.apache.servicemix.bundles.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: com.ning.billing/killbill-osgi-bundles-analytics
/**
* 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: com.ning.billing/killbill-osgi-bundles-jruby
/**
* 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());
}
内容来源于网络,如有侵权,请联系作者删除!