本文整理了Java中org.joda.time.LocalDateTime.getMinuteOfHour()
方法的一些代码示例,展示了LocalDateTime.getMinuteOfHour()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDateTime.getMinuteOfHour()
方法的具体详情如下:
包路径:org.joda.time.LocalDateTime
类名称:LocalDateTime
方法名:getMinuteOfHour
[英]Get the minute of hour field value.
[中]获取小时分钟字段值。
代码示例来源:origin: qunarcorp/qmq
private static long minute(final LocalDateTime localDateTime) {
return localDateTime.getMinuteOfHour();
}
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
protected Calendar dateToCalendar(Date date, TimeZone offerTimeZone) {
DateTimeZone offerDateTimeZone = DateTimeZone.forTimeZone(offerTimeZone);
LocalDateTime offerDateTime = new LocalDateTime(date, offerDateTimeZone);
Calendar calendar = new GregorianCalendar(offerTimeZone);
calendar.set(Calendar.YEAR, offerDateTime.getYear());
calendar.set(Calendar.MONTH, offerDateTime.getMonthOfYear() - 1);
calendar.set(Calendar.DAY_OF_MONTH, offerDateTime.getDayOfMonth());
calendar.set(Calendar.HOUR_OF_DAY, offerDateTime.getHourOfDay());
calendar.set(Calendar.MINUTE, offerDateTime.getMinuteOfHour());
calendar.set(Calendar.SECOND, offerDateTime.getSecondOfMinute());
calendar.get(Calendar.HOUR_OF_DAY);//do not delete this line
calendar.get(Calendar.MINUTE);
return calendar;
}
代码示例来源: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: 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: camunda/camunda-bpm-platform
int dom = getDayOfMonth();
Date date = new Date(getYear() - 1900, getMonthOfYear() - 1, dom,
getHourOfDay(), getMinuteOfHour(), getSecondOfMinute());
date.setTime(date.getTime() + getMillisOfSecond());
LocalDateTime check = LocalDateTime.fromDateFields(date);
代码示例来源: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: org.assertj/assertj-joda-time
/**
* Returns true if both datetime are in the same year, month, day of month, hour and minute, false otherwise.
*
* @param actual the actual datetime. expected not be null
* @param other the other datetime. expected not be null
* @return true if both datetime are in the same year, month, day of month, hour and minute, false otherwise.
*/
private static boolean areEqualIgnoringSeconds(LocalDateTime actual, LocalDateTime other) {
return areEqualIgnoringMinutes(actual, other) && actual.getMinuteOfHour() == other.getMinuteOfHour();
}
代码示例来源:origin: stackoverflow.com
Date toQuaterOfHour(Date date) {
LocalDateTime ldt = new LocalDateTime(date.getTime());
int quater = ldt.getMinuteOfHour() / 15;
return ldt.withMinuteOfHour(quater * 15).toDate();
}
代码示例来源:origin: dremio/dremio-oss
public TimePrintMillis(LocalDateTime time) {
super(time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute());
millisOfSecond = time.getMillisOfSecond();
}
代码示例来源: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-jruby
/**
* 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: redfish64/TinyTravelTracker
/**
* 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));
}
}
内容来源于网络,如有侵权,请联系作者删除!