Example usage for org.apache.commons.lang.time DateUtils addHours

List of usage examples for org.apache.commons.lang.time DateUtils addHours

Introduction

In this page you can find the example usage for org.apache.commons.lang.time DateUtils addHours.

Prototype

public static Date addHours(Date date, int amount) 

Source Link

Document

Adds a number of hours to a date returning a new object.

Usage

From source file:de.hybris.platform.acceleratorservices.order.strategies.impl.CustomerServiceUncollectedConsignmentStrategyTest.java

@Test
public void testProcessConsignmentNOK() {
    BDDMockito.given(consignmentModel.getShippingDate())
            .willReturn(DateUtils.addHours(referenceDate, 0 - timeThreshold.intValue() + 1));

    final boolean result = customerServiceUncollectedConsignmentStrategy.processConsignment(consignmentModel);

    Assert.assertFalse(result);/*from w  ww  .  jav  a 2  s.  com*/
}

From source file:de.hybris.platform.acceleratorservices.order.strategies.impl.ReminderUncollectedConsignmentStrategyTest.java

@Test
public void testProcessConsignmentNOK() {
    BDDMockito.given(consignmentModel.getShippingDate())
            .willReturn(DateUtils.addHours(referenceDate, 0 - timeThreshold.intValue() + 1));

    final boolean result = reminderUncollectedConsignmentStrategy.processConsignment(consignmentModel);

    Assert.assertFalse(result);//from  w ww .  jav  a 2  s . c o  m
}

From source file:fr.amapj.service.services.mescontrats.ContratDTO.java

/**
 * Indique si le contrat est modifiable//from  ww w  .j  av a  2 s  .  c  o m
 */
public boolean isModifiable() {
    Date d = DateUtils.addHours(dateFinInscription, 23);
    d = DateUtils.addMinutes(d, 59);
    return d.after(new Date());
}

From source file:de.hybris.platform.acceleratorservices.order.strategies.impl.CustomerServiceUncollectedConsignmentStrategyTest.java

@Test
public void testProcessConsignmentOKBusinessProcessExists() {
    BDDMockito.given(consignmentModel.getShippingDate())
            .willReturn(DateUtils.addHours(referenceDate, 0 - timeThreshold.intValue() - 1));
    BDDMockito.given(businessProcessService.getProcess(Mockito.anyString())).willReturn(businessProcessModel);

    final boolean result = customerServiceUncollectedConsignmentStrategy.processConsignment(consignmentModel);

    Assert.assertFalse(result);//  w w w.j ava  2  s .c o m
}

From source file:de.hybris.platform.acceleratorservices.order.strategies.impl.ReminderUncollectedConsignmentStrategyTest.java

@Test
public void testProcessConsignmentOKBusinessProcessExists() {
    BDDMockito.given(consignmentModel.getShippingDate())
            .willReturn(DateUtils.addHours(referenceDate, 0 - timeThreshold.intValue() - 1));
    BDDMockito.given(businessProcessService.getProcess(Mockito.anyString())).willReturn(businessProcessModel);

    final boolean result = reminderUncollectedConsignmentStrategy.processConsignment(consignmentModel);

    Assert.assertFalse(result);/*from  ww w. j  av  a  2  s . c  o  m*/
}

From source file:fr.xebia.demo.objectgrid.ticketing.test.AbstractTicketingGridTest.java

protected void loadData(EntityManager entityManager) {

    Random random = new Random();

    Date today = DateUtils.truncate(new Date(), Calendar.DAY_OF_MONTH);

    // PARIS-MARSEILLE
    for (int hour = 6; hour <= 24; hour++) {

        Train train = new Train(random.nextInt(), "PARIS-MARSEILLE-" + hour, Type.HIGH_SPEED);
        train.getTrainStops()/*from   w w  w .j av a  2  s . c om*/
                .add(new TrainStop(random.nextInt(), DateUtils.addHours(today, hour), PARIS_GARE_DE_LYON));
        train.getTrainStops()
                .add(new TrainStop(random.nextInt(), DateUtils.addHours(today, 2 + hour), AVIGNON_TGV));
        train.getTrainStops().add(
                new TrainStop(random.nextInt(), DateUtils.addHours(today, 3 + hour), MARSEILLE_SAINT_CHARLES));
        for (int seatNumber = 1; seatNumber <= 10; seatNumber++) {
            train.getSeats().add(
                    new Seat(random.nextInt(), seatNumber, random.nextBoolean(), 100 + random.nextInt(100)));
        }

        logger.info("persist " + train);
        entityManager.getTransaction().begin();
        entityManager.persist(train);
        entityManager.getTransaction().commit();
        persistedTrainIds.add(train.getId());
    }

    // MARSEILLE-PARIS
    for (int hour = 6; hour <= 24; hour++) {

        Train train = new Train(random.nextInt(), "MARSEILLE-PARIS-" + hour, Type.HIGH_SPEED);
        train.getTrainStops()
                .add(new TrainStop(random.nextInt(), DateUtils.addHours(today, hour), MARSEILLE_SAINT_CHARLES));
        train.getTrainStops()
                .add(new TrainStop(random.nextInt(), DateUtils.addHours(today, 1 + hour), AVIGNON_TGV));
        train.getTrainStops()
                .add(new TrainStop(random.nextInt(), DateUtils.addHours(today, 3 + hour), PARIS_GARE_DE_LYON));
        for (int seatNumber = 1; seatNumber <= 10; seatNumber++) {
            train.getSeats().add(
                    new Seat(random.nextInt(), seatNumber, random.nextBoolean(), 200 + random.nextInt(100)));
        }

        logger.info("persist " + train);
        entityManager.getTransaction().begin();
        entityManager.persist(train);
        entityManager.getTransaction().commit();
        persistedTrainIds.add(train.getId());
    }

}

From source file:cec.easyshop.facades.process.email.context.ConsignmentCollectionReminderEmailContext.java

@Override
public void init(final ConsignmentProcessModel consignmentProcessModel, final EmailPageModel emailPageModel) {
    super.init(consignmentProcessModel, emailPageModel);
    orderCode = consignmentProcessModel.getConsignment().getOrder().getCode();
    orderGuid = consignmentProcessModel.getConsignment().getOrder().getGuid();
    consignmentData = getConsignmentConverter().convert(consignmentProcessModel.getConsignment());
    guest = CustomerType.GUEST.equals(getCustomer(consignmentProcessModel).getType());
    final DateFormat dateFormat = getFormatFactory().createDateTimeFormat(DateFormat.MEDIUM, -1);
    pickUpDate = dateFormat/*from  w ww. j a  v  a2 s .  co m*/
            .format(DateUtils.addHours(consignmentProcessModel.getConsignment().getShippingDate(),
                    getCustomerServiceUncollectedConsignmentStrategy().getTimeThreshold().intValue()));
    orderData = getOrderConverter().convert((OrderModel) consignmentProcessModel.getConsignment().getOrder());
}

From source file:com.ctc.facades.process.email.context.ConsignmentCollectionReminderEmailContext.java

@Override
public void init(final ConsignmentProcessModel consignmentProcessModel, final EmailPageModel emailPageModel) {
    super.init(consignmentProcessModel, emailPageModel);
    orderCode = consignmentProcessModel.getConsignment().getOrder().getCode();
    orderGuid = consignmentProcessModel.getConsignment().getOrder().getGuid();
    consignmentData = getConsignmentConverter().convert(consignmentProcessModel.getConsignment());
    guest = CustomerType.GUEST.equals(getCustomer(consignmentProcessModel).getType());
    final DateFormat dateFormat = getFormatFactory().createDateTimeFormat(DateFormat.MEDIUM, -1);
    pickUpDate = dateFormat//from  w  ww  .  j a  v a  2  s  . c o m
            .format(DateUtils.addHours(consignmentProcessModel.getConsignment().getShippingDate(),
                    getCustomerServiceUncollectedConsignmentStrategy().getTimeThreshold().intValue()));
    orderData = getOrderConverter().convert((OrderModel) consignmentProcessModel.getConsignment().getOrder());
    if (LOG.isDebugEnabled()) {
        LOG.debug("Initialized with order code " + orderCode);
    }
}

From source file:com.edgenius.wiki.quartz.RemoveSpaceJobInvoker.java

public void invokeJob(String spaceUname, String removerUsername, int delayHours) throws QuartzException {
    //this setting are impact exportJobs() method
    TriggerKey triggerKey = new TriggerKey(REMOVE_SPACE_TRIGGER + spaceUname, QUARTZ_EXPORTABLE_JOB_GROUP);
    removeSpaceJob = JobBuilder.newJob(RemoveSpaceJob.class)
            .withIdentity(REMOVE_SPACE_JOB_PRE + spaceUname, QUARTZ_EXPORTABLE_JOB_GROUP)
            .withDescription(spaceUname + ":" + removerUsername)
            .usingJobData(WikiConstants.ATTR_SPACE_UNAME, spaceUname).storeDurably().requestRecovery().build();

    //delay given hours
    //      Date startDate = DateUtils.addSeconds(new Date(), delayHours);
    Date startDate = DateUtils.addHours(new Date(), delayHours);
    // start the scheduling job
    try {/*from w w  w .  j a  v  a  2 s  . c  o m*/
        cancelJob(spaceUname);

        Trigger trigger = TriggerBuilder.newTrigger().withIdentity(triggerKey).startAt(startDate).build();
        scheduler.scheduleJob(removeSpaceJob, trigger);
        log.info("Remove space " + spaceUname + " is scheduled in " + delayHours + " hours later.");
    } catch (SchedulerException e) {
        log.error("Error occurred at [RemoveSpace Schedule]- fail to start scheduling:", e);
        throw new QuartzException("Error occurred at [RemoveSpace Schedule]- fail to start scheduling", e);
    }
}

From source file:de.hybris.platform.acceleratorservices.order.strategies.impl.ReminderUncollectedConsignmentStrategyTest.java

@Test
public void testProcessConsignmentOKNoBusinessProcessExists() {
    BDDMockito.given(consignmentModel.getShippingDate())
            .willReturn(DateUtils.addHours(referenceDate, 0 - timeThreshold.intValue() - 1));
    BDDMockito.given(businessProcessService.getProcess(Mockito.anyString())).willReturn(null);
    BDDMockito.given(businessProcessService.createProcess(Mockito.anyString(), Mockito.anyString()))
            .willReturn(consignmentProcessModel);

    reminderUncollectedConsignmentStrategy.processConsignment(consignmentModel);

    Assert.assertTrue(true);/*ww w  .ja  v  a2  s  .co  m*/
    Mockito.verify(consignmentProcessModel).setConsignment(consignmentModel);
    Mockito.verify(modelService).save(consignmentProcessModel);
    Mockito.verify(businessProcessService).startProcess(consignmentProcessModel);
}