本文整理了Java中org.joda.time.LocalTime.toDateTime()
方法的一些代码示例,展示了LocalTime.toDateTime()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalTime.toDateTime()
方法的具体详情如下:
包路径:org.joda.time.LocalTime
类名称:LocalTime
方法名:toDateTime
[英]Converts this LocalTime to a full datetime using the default time zone setting the time fields from this instance and the date fields from the current date.
[中]使用默认时区设置此实例的时间字段和当前日期的日期字段,将此LocalTime转换为完整日期时间。
代码示例来源:origin: prestodb/presto
return new LocalDate(2001, 8, 22).toDateMidnight(DateTimeZone.UTC).getMillis();
case "bound_time":
return new LocalTime(3, 4, 5, 321).toDateTime(new DateTime(0, DateTimeZone.UTC)).getMillis();
case "bound_timestamp":
return new DateTime(2001, 8, 22, 3, 4, 5, 321, DateTimeZone.UTC).getMillis();
代码示例来源:origin: stackoverflow.com
LocalTime localTime = new LocalTime( 13 , 15 ); // Quarter-hour after 1 PM.
System.out.println( "localTime: " + localTime );
DateTimeZone timeZone = DateTimeZone.forID( "America/Montreal" ); // Or DateTimeZone.UTC
DateTime today = localTime.toDateTimeToday( timeZone );
DateTime now = DateTime.now(); // You may want to pad an bit of extra time in case now is extremely close to midnight (new day).
if ( today.isBefore( now ) ) {
// If the local time in question when applied to today has already past, then
// adjust to tomorrow while accounting for Daylight Saving Time or other anomaly.
DateTime tomorrowInitial = today.plusDays( 1 ); // Get tomorrow by adding 1 day to today.
DateTime tomorrow = localTime.toDateTime( tomorrowInitial ); // DST or other anomaly may mean that tomorrow got adjusted to a different time-of-day. Override with our desired time-of-day.
System.out.println( "tomorrow: " + tomorrow );
// return tomorrow;
}
System.out.println( "today: " + today );
// return today;
代码示例来源:origin: qcadoo/mes
public DateTimeRange(final DateTime day, final TimeRange range) {
DateTime from;
DateTime to;
if (range.startsDayBefore()) {
to = range.getTo().toDateTime(day.plusDays(1));
} else {
to = range.getTo().toDateTime(day);
}
from = range.getFrom().toDateTime(day);
interval = new Interval(from, to);
}
代码示例来源:origin: apiman/apiman
/**
* Returns true if the given DateTime matches the time range indicated by the
* filter/rule.
* @param currentTime
* @param filter
*/
private boolean matchesTime(TimeRestrictedAccess filter) {
Date start = filter.getTimeStart();
Date end = filter.getTimeEnd();
if (end == null || start == null) {
return true;
}
long startMs = start.getTime();
long endMs = end.getTime();
DateTime currentTime = new LocalTime(DateTimeZone.UTC).toDateTime(new DateTime(0l));
long nowMs = currentTime.toDate().getTime();
return nowMs >= startMs && nowMs < endMs;
}
代码示例来源:origin: Jasig/uPortal
@Override
public DateTime getDateTime() {
DateTime dt = this.dateTime;
if (dt == null) {
dt = this.timeDimension.getTime().toDateTime(this.dateDimension.getDate());
this.dateTime = dt;
}
return dt;
}
代码示例来源:origin: org.kuali.kpme/kpme-tk-lm-impl
public void setActionTime(String actionTime) {
if (StringUtils.isNotBlank(actionTime)) {
setLocalTime(actionTime != null ? FORMATTER.parseLocalTime(actionTime) : null);
if (localDate != null
&& localTime != null) {
actionDateTime = localTime.toDateTime(localDate.toDateTimeAtStartOfDay()).toDate();
}
}
}
代码示例来源:origin: org.actframework/act-morphia
@Override
public Object encode(Object value, MappedField optionalExtraInfo) {
if (null == value) {
return null;
}
if (value instanceof DateTime) {
DateTime dateTime = (DateTime) value;
return dateTime.getMillis();
} else if (value instanceof LocalDateTime) {
LocalDateTime localDateTime = (LocalDateTime) value;
return localDateTime.toDateTime().getMillis();
} else if (value instanceof LocalDate) {
LocalDate localDate = (LocalDate) value;
return localDate.toDateTimeAtStartOfDay().getMillis();
} else if (value instanceof LocalTime) {
LocalTime localTime = (LocalTime) value;
return localTime.toDateTime(new DateTime(0)).getMillis();
} else {
assert false;
return null;
}
}
代码示例来源:origin: qcadoo/mes
private DateRange buildDateRangeFrom(final TimeRange timeRange, final Date date) {
DateTime dateTime = new DateTime(date);
DateTime midnight = dateTime.withTimeAtStartOfDay();
DateTime from;
DateTime to;
if (timeRange.startsDayBefore()) {
if (dateTime.toLocalTime().isBefore(timeRange.getFrom())) {
from = timeRange.getFrom().toDateTime(midnight.minusDays(1));
to = timeRange.getTo().toDateTime(midnight);
} else {
from = timeRange.getFrom().toDateTime(midnight);
to = timeRange.getTo().toDateTime(midnight.plusDays(1));
}
} else {
from = timeRange.getFrom().toDateTime(midnight);
to = timeRange.getTo().toDateTime(midnight);
}
return new DateRange(from.toDate(), to.toDate());
}
代码示例来源:origin: stackoverflow.com
import org.joda.time.DateTime;
import org.joda.time.DateTimeConstants;
import org.joda.time.Interval;
import org.joda.time.LocalTime;
public class Main {
public static void main(String[] args) {
Interval interval = betweenNowAndNext(DateTimeConstants.MONDAY, new LocalTime(10, 14));
System.out.println(interval.toDurationMillis());
}
public static Interval betweenNowAndNext(int dayOfWeek, LocalTime time) {
DateTime now = DateTime.now();
DateTime closest = time.toDateTime(now).withDayOfWeek(dayOfWeek);
return new Interval(now, closest.isBefore(now) ? closest.plusWeeks(1) : closest);
}
}
代码示例来源:origin: stackoverflow.com
this(from == null ? null : from.toDateTime(INSTANT),
to == null ? null : to.toDateTime(INSTANT));
代码示例来源:origin: org.kuali.kpme/kpme-tk-lm-impl
protected List<Shift> createShifts(ShiftDifferentialRule rule, LocalDateTime spanBegin, LocalDateTime spanEnd, DateTimeZone zone) {
DateTime spanBeginDT = spanBegin.toDateTime(zone);
DateTime spanEndDT = spanEnd.toDateTime(zone);
Interval calendarEntryInterval = new Interval(spanBeginDT, spanEndDT);
DateTime shiftEnd = LocalTime.fromDateFields(rule.getEndTime()).toDateTime(spanBeginDT).minusDays(1);
DateTime shiftStart = LocalTime.fromDateFields(rule.getBeginTime()).toDateTime(spanBeginDT).minusDays(1);
if (shiftEnd.isBefore(shiftStart) || shiftEnd.isEqual(shiftStart)) {
shiftEnd = shiftEnd.plusDays(1);
}
List<Shift> shifts = new ArrayList<Shift>();
Interval shiftInterval = new Interval(shiftStart, shiftEnd);
//possible that there is no overlap between 1st interval and cal entry interval... if so, add a day.
if (!calendarEntryInterval.overlaps(shiftInterval)) {
shiftInterval = incrementShift(shiftInterval);
}
while (calendarEntryInterval.overlaps(shiftInterval)) {
if (ruleIsActiveForDay(shiftInterval.getStart(), rule)) {
shifts.add(new Shift(rule, shiftInterval, zone));
}
shiftInterval = incrementShift(shiftInterval);
}
return shifts;
}
代码示例来源:origin: org.kuali.kpme/kpme-tk-lm-impl
LocalTime ruleEnd = new LocalTime(rule.getEndTime());
DateTime beginShiftEnd = ruleEnd.toDateTime(calEntryBegin.minusDays(1));
DateTime beginShiftStart = ruleStart.toDateTime(calEntryBegin.minusDays(1));
DateTime endShiftEnd = ruleEnd.toDateTime(calEntryEnd);
DateTime endShiftBegin = ruleStart.toDateTime(calEntryEnd);
代码示例来源:origin: uk.co.nichesolutions.presto/presto-main
@Override
public Object getValue(Symbol symbol)
{
switch (symbol.getName().toLowerCase(ENGLISH)) {
case "bound_long":
return 1234L;
case "bound_string":
return utf8Slice("hello");
case "bound_double":
return 12.34;
case "bound_date":
return new LocalDate(2001, 8, 22).toDateMidnight(DateTimeZone.UTC).getMillis();
case "bound_time":
return new LocalTime(3, 4, 5, 321).toDateTime(new DateTime(0, DateTimeZone.UTC)).getMillis();
case "bound_timestamp":
return new DateTime(2001, 8, 22, 3, 4, 5, 321, DateTimeZone.UTC).getMillis();
case "bound_pattern":
return utf8Slice("%el%");
case "bound_timestamp_with_timezone":
return new SqlTimestampWithTimeZone(new DateTime(1970, 1, 1, 1, 0, 0, 999, DateTimeZone.UTC).getMillis(), getTimeZoneKey("Z"));
case "bound_varbinary":
return Slices.wrappedBuffer((byte) 0xab);
}
return new QualifiedNameReference(symbol.toQualifiedName());
}
});
代码示例来源:origin: com.sap.cloud.s4hana.datamodel/odata-core
} else if( comparisonValue instanceof org.joda.time.LocalTime ) {
final Date date =
((org.joda.time.LocalTime) comparisonValue).toDateTime(new DateTime(0, DateTimeZone.UTC)).toDate();
odataExpr = new FilterExpression(fieldName, function, ODataType.of(date));
} else if( comparisonValue instanceof org.joda.time.LocalDateTime ) {
代码示例来源:origin: io.prestosql/presto-main
return new LocalDate(2001, 8, 22).toDateMidnight(DateTimeZone.UTC).getMillis();
case "bound_time":
return new LocalTime(3, 4, 5, 321).toDateTime(new DateTime(0, DateTimeZone.UTC)).getMillis();
case "bound_timestamp":
return new DateTime(2001, 8, 22, 3, 4, 5, 321, DateTimeZone.UTC).getMillis();
代码示例来源:origin: prestosql/presto
return new LocalDate(2001, 8, 22).toDateMidnight(DateTimeZone.UTC).getMillis();
case "bound_time":
return new LocalTime(3, 4, 5, 321).toDateTime(new DateTime(0, DateTimeZone.UTC)).getMillis();
case "bound_timestamp":
return new DateTime(2001, 8, 22, 3, 4, 5, 321, DateTimeZone.UTC).getMillis();
内容来源于网络,如有侵权,请联系作者删除!