Example usage for org.joda.time LocalDateTime LocalDateTime

List of usage examples for org.joda.time LocalDateTime LocalDateTime

Introduction

In this page you can find the example usage for org.joda.time LocalDateTime LocalDateTime.

Prototype

public LocalDateTime() 

Source Link

Document

Constructs an instance set to the current local time evaluated using ISO chronology in the default zone.

Usage

From source file:uk.co.onehp.trickle.services.betfair.BetfairServiceImpl.java

License:Open Source License

private PlaceBets createMOCExchangeBet(Bet bet, BigDecimal liability, BigDecimal price) {
    bet.addLog(new BetLog(new LocalDateTime(), liability, price, BetType.MOC_EXCHANGE));
    this.domainService.updateBet(bet);
    PlaceBets placeBets = new PlaceBets();
    placeBets.setBetType(bet.getStrategy().getAspect() == BettingAspect.BACK ? BetTypeEnum.B : BetTypeEnum.L);
    placeBets.setBetCategoryType(BetCategoryTypeEnum.E);
    placeBets.setBetPersistenceType(BetPersistenceTypeEnum.SP);
    placeBets.setMarketId(bet.getHorse().getRaceId());
    placeBets.setSelectionId(bet.getHorse().getRunnerId());
    placeBets.setSize(bet.getStrategy().getAspect() == BettingAspect.BACK ? liability.doubleValue()
            : BettingUtil.libilityToStake(liability, price).doubleValue());
    placeBets.setPrice(price.doubleValue());
    //Workaround for known bug in betfair
    placeBets.setBspLiability(0.0);//  www. j ava2s .  co m
    return placeBets;
}

From source file:uk.co.onehp.trickle.services.betfair.BetfairServiceImpl.java

License:Open Source License

private void sendRequest(Object body) {
    if (body.getClass() != LoginReq.class) {
        if (this.sessionService.getGlobalSessionTokenUpdateDateTime().plusSeconds(this.sessionTimeout)
                .isBefore(new LocalDateTime())) {
            login();/*from ww w  .j  av a 2s  .c o m*/
        }
    }
    final Map<String, Object> headers = Maps.newHashMap();
    headers.put("requestType", body.getClass().toString());
    this.producerTemplate.sendBodyAndHeaders("jms:betfair", new Gson().toJson(body), headers);
}

From source file:uk.co.onehp.trickle.services.betfair.ScheduledServiceImpl.java

License:Open Source License

@Override
@Scheduled(cron = "0 5 5 * * *")
public void getAllRaces() {
    LocalDateTime now = new LocalDateTime();
    for (Race race : this.domainService.getAllRaces()) {
        if (race.getStartTime().isAfter(now)) {
            this.betfairService.getRace(race.getEventId());
        }/*  w w w . jav  a 2  s  .com*/
    }
}

From source file:uk.co.onehp.trickle.services.betfair.ScheduledServiceImpl.java

License:Open Source License

@Override
@Scheduled(cron = "0 0 6 * * *")
public void getAllRacePrices() {
    LocalDateTime now = new LocalDateTime();
    for (Race race : this.domainService.getAllRaces()) {
        if (race.getStartTime().isAfter(now)) {
            this.betfairService.getRacePrices(race.getEventId());
        }//from  ww  w. j a v a 2  s  .  c o  m
    }
}

From source file:uk.co.onehp.trickle.services.betfair.ScheduledServiceImpl.java

License:Open Source License

private String nextBetSchedule() {
    LocalDateTime nextBetTime = this.domainService.getNextBetTime();
    if (null == nextBetTime) {
        nextBetTime = new LocalDateTime().plusMinutes(1);
    }//from w  w  w  .  ja  v a 2  s.  c om
    String cron = String.format("%s %s %s %s %s ?", nextBetTime.getSecondOfMinute(),
            nextBetTime.getMinuteOfHour(), nextBetTime.getHourOfDay(), nextBetTime.getDayOfMonth(),
            nextBetTime.getMonthOfYear());
    return cron;
}

From source file:uk.co.onehp.trickle.services.betfair.ScheduledServiceImpl.java

License:Open Source License

private String nextBetPriceSchedule() {
    LocalDateTime nextBetTime = this.domainService.getNextBetTime();
    if (null == nextBetTime) {
        nextBetTime = new LocalDateTime().plusMinutes(1);
    } else {/*from ww  w  .  j a v  a2s.  c o  m*/
        nextBetTime = nextBetTime.minusSeconds(this.upcomingBetsSeconds);
    }
    String cron = String.format("%s %s %s %s %s ?", nextBetTime.getSecondOfMinute(),
            nextBetTime.getMinuteOfHour(), nextBetTime.getHourOfDay(), nextBetTime.getDayOfMonth(),
            nextBetTime.getMonthOfYear());
    return cron;
}

From source file:uk.co.onehp.trickle.services.domain.DomainServiceImpl.java

License:Open Source License

@Override
@Transactional//from w ww .  j  a  v  a 2  s.c o m
public void archiveMeetings() {
    List<Meeting> allMeetings = this.meetingDao.getAllMeetings();
    for (Meeting meeting : allMeetings) {
        if (meeting.getRaces().get(0).getStartTime()
                .isBefore(new LocalDateTime().withHourOfDay(0).withMinuteOfHour(0))) {
            for (Race race : meeting.getRaces()) {
                race.markAsComplete();
                this.raceDao.saveOrUpdate(race);
            }
            meeting.markAsComplete();
            this.meetingDao.saveOrUpdate(meeting);
        }
    }
}

From source file:view.popups.shift.ShiftPopup.java

private void initComboboxes() {

    cDate = new ComboBox();
    cDate.setPrefWidth(170);//from  w  w  w. ja va 2  s  .c  o  m

    LocalDateTime now = new LocalDateTime();
    now = now.withHourOfDay(0);
    now = now.withMinuteOfHour(0);
    LocalDateTime currentWeek = now;

    LocalDateTime threeMonthsForward = now.plusMonths(3);
    ArrayList<LocalDateTime> startDates = Xray.getInstance().getDatesInPeriod(currentWeek, threeMonthsForward);
    for (int i = 0; i < startDates.size(); i++) {
        if (startDates.get(i).getDayOfWeek() == 1) {
            cDate.getItems().add(startDates.get(i));
        }
    }

    Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>> cellFactory = new Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>>() {
        @Override
        public ListCell<LocalDateTime> call(ListView<LocalDateTime> param) {

            return new ListCell<LocalDateTime>() {
                @Override
                public void updateItem(LocalDateTime item, boolean empty) {
                    super.updateItem(item, empty);
                    if (!empty) {
                        String value = ScheduleHeader.WEEK_DAY_NAMES[item.getDayOfWeek() - 1];
                        value = value.replaceFirst(value.substring(1, value.length()),
                                value.substring(1, value.length()).toLowerCase());
                        setText("Uge " + item.getWeekOfWeekyear() + " den " + item.getDayOfMonth() + "/"
                                + item.getMonthOfYear() + " - " + value);
                    }
                }

            };
        }
    };

    cDate.setButtonCell(cellFactory.call(null));
    cDate.setCellFactory(cellFactory);

    cEmployee = new ComboBox();
    cEmployee.setPrefWidth(170);
    cEmployee.setDisable(true);

}

From source file:view.popups.TimeInvestmentPopup.java

private void fillContent() {
    //Fyld datoer ind i comboboks til start og slutdato:
    LocalDateTime now = new LocalDateTime();
    LocalDateTime oneWeekBack = now.minusMonths(12);
    LocalDateTime oneMonthForward = now.plusMonths(12);
    ArrayList<LocalDateTime> startDates = Xray.getInstance().getDatesInPeriod(oneWeekBack, oneMonthForward);
    for (int i = 0; i < startDates.size(); i++) {
        cStart.getItems().add(startDates.get(i));
    }/*from   ww w. ja  va2s .  com*/
    cStart.getSelectionModel().selectFirst();

    //Lav et cellfactory p comboboksen s datoerne vises overskueligt.
    Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>> cellFactory = new Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>>() {
        @Override
        public ListCell<LocalDateTime> call(ListView<LocalDateTime> param) {

            return new ListCell<LocalDateTime>() {
                @Override
                public void updateItem(LocalDateTime item, boolean empty) {
                    super.updateItem(item, empty);
                    if (!empty) {
                        String dayName = ScheduleHeader.WEEK_DAY_NAMES[item.getDayOfWeek() - 1];
                        setText(item.toString("dd/MM/yy") + " " + dayName.substring(0, 1)
                                + dayName.substring(1).toLowerCase());
                    }
                }

            };
        }
    };

    Xray.getInstance().fillDatesInEndDate(cEnd, cStart, 12);

    cStart.setButtonCell(cellFactory.call(null));
    cStart.setCellFactory(cellFactory);
    cEnd.setButtonCell(cellFactory.call(null));
    cEnd.setCellFactory(cellFactory);

}

From source file:view.popups.timePeriod.AddTimePeriodPopup.java

private void fillContent() {
    try {/*from  w  ww.ja  v a 2  s . c om*/
        ArrayList<Employee> employees = Xray.getInstance().getPersonControl().getEmployees();

        for (int i = 0; i < employees.size(); i++) {
            cEmp.getItems().add(employees.get(i));
        }
        cEmp.getSelectionModel().selectFirst();
    } catch (DatabaseException ex) {
        new ExceptionPopup().display(ex.getMessage());
    }

    try {
        ArrayList<Room> rooms = Xray.getInstance().getRoomControl().getRooms();

        for (int i = 0; i < rooms.size(); i++) {
            cRoom.getItems().add(rooms.get(i));
        }
        cRoom.getSelectionModel().selectFirst();
    } catch (DatabaseException ex) {
        new ExceptionPopup().display(ex.getMessage());
    }

    //Fyld datoer ind i comboboks til start og slutdato:
    LocalDateTime now = new LocalDateTime();
    LocalDateTime oneWeekBack = now.minusDays(7);
    LocalDateTime oneMonthForward = now.plusMonths(1);
    ArrayList<LocalDateTime> startDates = Xray.getInstance().getDatesInPeriod(oneWeekBack, oneMonthForward);
    for (int i = 0; i < startDates.size(); i++) {
        cStart.getItems().add(startDates.get(i));
    }
    cStart.getSelectionModel().selectFirst();

    //Lav et cellfactory p comboboksen s datoerne vises overskueligt.
    Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>> cellFactory = new Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>>() {
        @Override
        public ListCell<LocalDateTime> call(ListView<LocalDateTime> param) {

            return new ListCell<LocalDateTime>() {
                @Override
                public void updateItem(LocalDateTime item, boolean empty) {
                    super.updateItem(item, empty);
                    if (!empty) {
                        String dayName = ScheduleHeader.WEEK_DAY_NAMES[item.getDayOfWeek() - 1];
                        setText(item.toString("dd/MM") + " " + dayName.substring(0, 1)
                                + dayName.substring(1).toLowerCase());
                    }
                }

            };
        }
    };

    Xray.getInstance().fillDatesInEndDate(cEnd, cStart, 1);

    cStart.setButtonCell(cellFactory.call(null));
    cStart.setCellFactory(cellFactory);
    cEnd.setButtonCell(cellFactory.call(null));
    cEnd.setCellFactory(cellFactory);

}