Java Code Examples for org.joda.time.Instant#toDate()

The following examples show how to use org.joda.time.Instant#toDate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimplifiedKinesisClient.java    From beam with Apache License 2.0 6 votes vote down vote up
public String getShardIterator(
    final String streamName,
    final String shardId,
    final ShardIteratorType shardIteratorType,
    final String startingSequenceNumber,
    final Instant timestamp)
    throws TransientKinesisException {
  final Date date = timestamp != null ? timestamp.toDate() : null;
  return wrapExceptions(
      () ->
          kinesis
              .getShardIterator(
                  new GetShardIteratorRequest()
                      .withStreamName(streamName)
                      .withShardId(shardId)
                      .withShardIteratorType(shardIteratorType)
                      .withStartingSequenceNumber(startingSequenceNumber)
                      .withTimestamp(date))
              .getShardIterator());
}
 
Example 2
Source File: RetryPolicy.java    From mireka with Apache License 2.0 6 votes vote down vote up
public void actOnPostponeRequired(Mail mail, PostponeException e)
        throws LocalMailSystemException {
    mail.postpones++;
    if (mail.postpones <= 3) {
        Instant newScheduleDate =
                new DateTime().plusSeconds(e.getRecommendedDelay())
                        .toInstant();
        mail.scheduleDate = newScheduleDate.toDate();
        retryTransmitter.transmit(mail);
        logger.debug("Delivery must be postponed to all hosts. "
                + "Rescheduling the attempt. This is the " + mail.postpones
                + ". postponing of this delivery attempt.");

    } else {
        logger.debug("Too much postponings of delivery attempt. "
                + "The next would be the " + mail.postpones
                + ". Attempt is considered to be a failure.");
        SendException sendException =
                new SendException(
                        "Too much postponings of delivery attempt, attempt is considered to be a failure.",
                        e, e.getEnhancedStatus());
        EntireMailFailureHandler failureHandler =
                new EntireMailFailureHandler(mail, sendException);
        failureHandler.onFailure();
    }
}
 
Example 3
Source File: RetryPolicy.java    From mireka with Apache License 2.0 5 votes vote down vote up
private void rescheduleTemporaryFailures()
        throws LocalMailSystemException {
    if (transientFailures.isEmpty())
        return;
    Period waitingPeriod = retryPeriods.get(mail.deliveryAttempts - 1);
    Instant newScheduleDate =
            new DateTime().plus(waitingPeriod).toInstant();
    mail.scheduleDate = newScheduleDate.toDate();
    mail.recipients = calculateTemporarilyRejectedRecipientList();
    retryTransmitter.transmit(mail);
    logger.debug("Transient failure, the mail is scheduled for a "
            + (mail.deliveryAttempts + 1) + ". attempt "
            + waitingPeriod + " later on " + newScheduleDate);
}
 
Example 4
Source File: JodaInstantTojuDateConverter.java    From SimpleFlatMapper with MIT License 4 votes vote down vote up
@Override
public Date convert(Instant in, Context context) throws Exception {
    if (in == null) return null;
    return in.toDate();
}