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

x33g5p2x  于2022-01-17 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(168)

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

DateTime.toLocalDate介绍

[英]Converts this object to a LocalDate with the same date and chronology.
[中]将此对象转换为具有相同日期和年表的LocalDate

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Override
  public LocalDate convert(DateTime source) {
    return source.toLocalDate();
  }
}

代码示例来源:origin: org.springframework/spring-context

@Override
  public LocalDate convert(DateTime source) {
    return source.toLocalDate();
  }
}

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

DateTime first = ...;
DateTime second = ...;

LocalDate firstDate = first.toLocalDate();
LocalDate secondDate = second.toLocalDate();

return firstDate.compareTo(secondDate);

代码示例来源:origin: spring-projects/spring-framework

@Override
  public LocalDate convert(DateTime source) {
    return source.toLocalDate();
  }
});

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

// 5am on the 20th to 1pm on the 21st, October 2013, Brazil
DateTimeZone BRAZIL = DateTimeZone.forID("America/Sao_Paulo");
DateTime start = new DateTime(2013, 10, 20, 5, 0, 0, BRAZIL);
DateTime end = new DateTime(2013, 10, 21, 13, 0, 0, BRAZIL);
System.out.println(daysBetween(start.withTimeAtStartOfDay(),
                end.withTimeAtStartOfDay()).getDays());
// prints 0
System.out.println(daysBetween(start.toLocalDate(),
                end.toLocalDate()).getDays());
// prints 1

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

public static String formatToYesterdayOrToday(String date) {
  DateTime dateTime = DateTimeFormat.forPattern("EEE hh:mma MMM d, yyyy").parseDateTime(date);
  DateTime today = new DateTime();
  DateTime yesterday = today.minusDays(1);
  DateTimeFormatter timeFormatter = DateTimeFormat.forPattern("hh:mma");

  if (dateTime.toLocalDate().equals(today.toLocalDate())) {
    return "Today " + timeFormatter.print(dateTime);
  } else if (dateTime.toLocalDate().equals(yesterday.toLocalDate())) {
    return "Yesterday " + timeFormatter.print(dateTime);
  } else {
    return date;
  }
}

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

/**
 * Returns a copy of this datetime with the time set to the start of the day.
 * <p>
 * The time will normally be midnight, as that is the earliest time on
 * any given day. However, in some time zones when Daylight Savings Time
 * starts, there is no midnight because time jumps from 11:59 to 01:00.
 * This method handles that situation by returning 01:00 on that date.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @return a copy of this datetime with the time set to the start of the day, not null
 */
public DateTime withTimeAtStartOfDay() {
  return toLocalDate().toDateTimeAtStartOfDay(getZone());
}

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

/**
 * Returns a copy of this datetime with the time set to the start of the day.
 * <p>
 * The time will normally be midnight, as that is the earliest time on
 * any given day. However, in some time zones when Daylight Savings Time
 * starts, there is no midnight because time jumps from 11:59 to 01:00.
 * This method handles that situation by returning 01:00 on that date.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @return a copy of this datetime with the time set to the start of the day, not null
 */
public DateTime withTimeAtStartOfDay() {
  return toLocalDate().toDateTimeAtStartOfDay(getZone());
}

代码示例来源:origin: prestodb/presto

@Description("current date")
@ScalarFunction
@SqlType(StandardTypes.DATE)
public static long currentDate(ConnectorSession session)
{
  ISOChronology chronology = getChronology(session.getTimeZoneKey());
  // It is ok for this method to use the Object interfaces because it is constant folded during
  // plan optimization
  LocalDate currentDate = new DateTime(session.getStartTime(), chronology).toLocalDate();
  return Days.daysBetween(new LocalDate(1970, 1, 1), currentDate).getDays();
}

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl

@Override
  public LocalDate deserialize(JsonParser jp, DeserializationContext ctxt)
    throws IOException, JsonProcessingException
  {
    // We'll accept either long (timestamp) or array:
    if (jp.isExpectedStartArrayToken()) {
      jp.nextToken(); // VALUE_NUMBER_INT 
      int year = jp.getIntValue(); 
      jp.nextToken(); // VALUE_NUMBER_INT
      int month = jp.getIntValue();
      jp.nextToken(); // VALUE_NUMBER_INT
      int day = jp.getIntValue();
      if (jp.nextToken() != JsonToken.END_ARRAY) {
        throw ctxt.wrongTokenException(jp, JsonToken.END_ARRAY, "after LocalDate ints");
      }
      return new LocalDate(year, month, day);
    }
    switch (jp.getCurrentToken()) {
    case VALUE_NUMBER_INT:
      return new LocalDate(jp.getLongValue());            
    case VALUE_STRING:
      DateTime local = parseLocal(jp);
      if (local == null) {
        return null;
      }
      return local.toLocalDate();
    }
    throw ctxt.wrongTokenException(jp, JsonToken.START_ARRAY, "expected JSON Array, String or Number");
  }
}

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

bundle.getExternalKey(),
specifiers,
init.toLocalDate(),
false);

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

/**
 * Returns a copy of this datetime with the time set to the start of the day.
 * <p>
 * The time will normally be midnight, as that is the earliest time on
 * any given day. However, in some time zones when Daylight Savings Time
 * starts, there is no midnight because time jumps from 11:59 to 01:00.
 * This method handles that situation by returning 01:00 on that date.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @return a copy of this datetime with the time set to the start of the day, not null
 */
public DateTime withTimeAtStartOfDay() {
  return toLocalDate().toDateTimeAtStartOfDay(getZone());
}

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

@Override
  public LocalDate deserialize(JsonParser jp, DeserializationContext ctxt)
    throws IOException, JsonProcessingException
  {
    // We'll accept either long (timestamp) or array:
    if (jp.isExpectedStartArrayToken()) {
      jp.nextToken(); // VALUE_NUMBER_INT 
      int year = jp.getIntValue(); 
      jp.nextToken(); // VALUE_NUMBER_INT
      int month = jp.getIntValue();
      jp.nextToken(); // VALUE_NUMBER_INT
      int day = jp.getIntValue();
      if (jp.nextToken() != JsonToken.END_ARRAY) {
        throw ctxt.wrongTokenException(jp, JsonToken.END_ARRAY, "after LocalDate ints");
      }
      return new LocalDate(year, month, day);
    }
    switch (jp.getCurrentToken()) {
    case VALUE_NUMBER_INT:
      return new LocalDate(jp.getLongValue());            
    case VALUE_STRING:
      DateTime local = parseLocal(jp);
      if (local == null) {
        return null;
      }
      return local.toLocalDate();
    }
    throw ctxt.wrongTokenException(jp, JsonToken.START_ARRAY, "expected JSON Array, String or Number");
  }
}

代码示例来源:origin: org.kuali.kpme/kpme-tk-lm-impl

private Map<String,Set<String>> findTransactionsWithinPeriod(LeaveCalendarDocumentHeader aDoc,
                               CalendarEntry payCalendarEntry) {
  Map<String,Set<String>> allMessages = new HashMap<String,Set<String>>();
  
  allMessages.put("actionMessages", new HashSet<String>());
  allMessages.put("infoMessages", new HashSet<String>());
  allMessages.put("warningMessages", new HashSet<String>());
  if(aDoc != null) {
    allMessages = LeaveCalendarValidationUtil.validatePendingTransactions(aDoc.getPrincipalId(), payCalendarEntry.getBeginPeriodFullDateTime().toLocalDate(), payCalendarEntry.getEndPeriodFullDateTime().toLocalDate());
  }
  return allMessages;
}

代码示例来源:origin: qcadoo/mes

public OrderRealizationDay find(final DateTime orderStartDateTime, final int startingFrom, final boolean isFirstDay,
    final List<Shift> shifts) {
  OrderRealizationDay firstWorkingDay = findFirstWorkingDayFrom(orderStartDateTime.toLocalDate(), startingFrom, shifts);
  if (isFirstDay) {
    return tryResolveFirstDay(firstWorkingDay, orderStartDateTime).or(firstWorkingDay);
  }
  return firstWorkingDay;
}

代码示例来源:origin: qcadoo/mes

public List<DateTimeRange> getShiftWorkDateTimes(final Entity productionLine, final Shift shift, DateTime dateOfDay) {
  List<TimeRange> shiftWorkTime = Lists.newArrayList();
  List<DateTimeRange> shiftWorkDateTime = Lists.newArrayList();
  if (shift.worksAt(dateOfDay.dayOfWeek().get())) {
    shiftWorkTime = shift.findWorkTimeAt(dateOfDay.toLocalDate());
  }
  for (TimeRange range : shiftWorkTime) {
    shiftWorkDateTime.add(new DateTimeRange(dateOfDay, range));
  }
  shiftWorkDateTime = manageExceptions(shiftWorkDateTime, productionLine, shift, dateOfDay.toDate());
  return shiftWorkDateTime;
}

代码示例来源:origin: qcadoo/mes

public static DeviationsReportCriteria forDates(final DateTime fromDate, final Optional<DateTime> maybeToDate) {
  checkArguments(fromDate, maybeToDate);
  LocalDate fromLocalDate = fromDate.toLocalDate();
  Optional<LocalDate> maybeToLocalDate = maybeToDate.transform(new Function<DateTime, LocalDate>() {
    @Override
    public LocalDate apply(final DateTime input) {
      return input.toLocalDate();
    }
  });
  return fromLocalDates(fromLocalDate, maybeToLocalDate);
}

代码示例来源:origin: qcadoo/mes

private Optional<DateTime> getShiftStartDate(DateTime day, Entity shift) {
  Shift shiftFirst = new Shift(shift);
  List<TimeRange> ranges = shiftFirst.findWorkTimeAt(day.toLocalDate());
  if (ranges.isEmpty()) {
    return Optional.empty();
  }
  LocalTime startTime = ranges.get(0).getFrom();
  DateTime startShitTime = day;
  startShitTime = startShitTime.withHourOfDay(startTime.getHourOfDay());
  startShitTime = startShitTime.withMinuteOfHour(startTime.getMinuteOfHour());
  return Optional.of(startShitTime);
}

代码示例来源:origin: org.kuali.kpme/kpme-tk-lm-impl

private void calculateMaxCarryOverForLeavePlan(String documentId, String principalId, CalendarEntry calendarEntry, String leavePlan, LocalDate asOfDate) {
  List<? extends AccrualCategoryContract> accrualCategories = getAccrualCategoryService().getActiveAccrualCategoriesForLeavePlan(leavePlan, asOfDate);
  
  for (AccrualCategoryContract accrualCategory : accrualCategories) {
    BigDecimal adjustmentAmount = getAccrualCategoryCarryOverAdjustment(accrualCategory.getAccrualCategory(), principalId, calendarEntry, asOfDate);
    
    if (adjustmentAmount.compareTo(BigDecimal.ZERO) > 0) {
      LocalDate LeaveDate = calendarEntry.getEndPeriodFullDateTime().toLocalDate().minusDays(1);
    
      addAdjustmentLeaveBlock(documentId, principalId, LeaveDate, accrualCategory, adjustmentAmount.negate());
    }
  }
}

代码示例来源:origin: org.kill-bill.billing/killbill-invoice

private InvoiceItemModelDao buildCBAItem(final InvoiceModelDao invoice,
                       final BigDecimal amount,
                       final InternalCallContext context) {
    return new InvoiceItemModelDao(new CreditBalanceAdjInvoiceItem(invoice.getId(),
                                    invoice.getAccountId(),
                                    context.getCreatedDate().toLocalDate(),
                                    amount.negate(),
                                    invoice.getCurrency()));
  }
}

相关文章

DateTime类方法