Examples of LocalTime


Examples of org.joda.time.LocalTime

     * @param   date  the query date.
     * @return  true if the specified date is within this session, false if not.
     */
    public boolean contains(DateTime date) {
        int otherDay = date.getDayOfWeek();
        LocalTime lt = date.toLocalTime();
       
        boolean startBounded = (lt.isEqual(start) || lt.isAfter(start));
        boolean endBounded = (lt.isEqual(end) || lt.isBefore(end));
        return dayIsWithinSessionDay(otherDay) &&
            ((startBounded && endBounded) ||
             (day != endDay &&
                ((otherDay == day && startBounded) ||
                 (otherDay == endDay && endBounded) ||
View Full Code Here

Examples of org.joda.time.LocalTime

        }
        while(!isWorkingDay(date.toLocalDate())) {
            date = date.plusDays(1);
        }
        int otherDay = date.getDayOfWeek();
        LocalTime lt = date.toLocalTime();
        int len = sessions.size();
        for(int i = 0;i < len;i++) {
            TradingSession ts = sessions.get(i);
            if(ts.contains(date)) {
                return ts;
View Full Code Here

Examples of org.joda.time.LocalTime

                    skip = true;
                }
            }
            case HOUR: {
                if(skip) {
                    LocalTime lt = tradingSession.start();
                    dt = dt.withHourOfDay(lt.getHourOfDay());
                }else{
                    dt = dt.plusHours(interval);
                    tradingSession = getTradingSessionOnOrAfter(dt);
                    if(!tradingSession.contains(dt)) {
                        if(tradingSession.day() < dt.getDayOfWeek()) {
                            dt = dt.plusDays((DateTimeConstants.SUNDAY - dt.getDayOfWeek()) + 1);
                        }
                        dt = dt.withDayOfWeek(tradingSession.day());
                        dt = dt.withHourOfDay(tradingSession.start().getHourOfDay());
                    }
                    skip = true;
                }
            }
            case MINUTE: {
                if(skip) {
                    LocalTime lt = tradingSession.start();
                    dt = dt.withMinuteOfHour(lt.getMinuteOfHour());
                }else{
                    dt = dt.plusMinutes(interval);
                    tradingSession = getTradingSessionOnOrAfter(dt);
                    if(!tradingSession.contains(dt)) {
                        if(tradingSession.day() < dt.getDayOfWeek()) {
                            dt = dt.plusDays((DateTimeConstants.SUNDAY - dt.getDayOfWeek()) + 1);
                        }
                        dt = dt.withDayOfWeek(tradingSession.day());
                        LocalTime lt = tradingSession.start();
                        dt = dt.withHourOfDay(lt.getHourOfDay()).withMinuteOfHour(lt.getMinuteOfHour());
                    }
                    skip = true;
                }
            }
            case SECOND: {
                if(skip) {
                    dt = dt.withSecondOfMinute(0);
                }else{
                    dt = dt.plusSeconds(interval);
                    tradingSession = getTradingSessionOnOrAfter(dt);
                    if(!tradingSession.contains(dt)) {
                        if(tradingSession.day() < dt.getDayOfWeek()) {
                            dt = dt.plusDays((DateTimeConstants.SUNDAY - dt.getDayOfWeek()) + 1);
                        }
                        dt = dt.withDayOfWeek(tradingSession.day());
                        LocalTime lt = tradingSession.start();
                        dt = dt.withHourOfDay(lt.getHourOfDay()).withMinuteOfHour(lt.getMinuteOfHour());
                        dt = dt.withSecondOfMinute(0);
                    }
                }
                break;
            }
            case TICK: {
              tradingSession = getTradingSessionOnOrAfter(dt);
                if(!tradingSession.contains(dt)) {
                    if(tradingSession.day() < dt.getDayOfWeek()) {
                        dt = dt.plusDays((DateTimeConstants.SUNDAY - dt.getDayOfWeek()) + 1);
                    }
                    dt = dt.withDayOfWeek(tradingSession.day());
                    LocalTime lt = tradingSession.start();
                    dt = dt.withHourOfDay(lt.getHourOfDay()).withMinuteOfHour(lt.getMinuteOfHour());
                    dt = dt.withSecondOfMinute(lt.getSecondOfMinute()).withMillisOfSecond(0);
                }
            }
           
            // Guarantee new date is aligned to a business date.
            calculator.setStartDate(dt.toLocalDate());
            LocalDate ldt = calculator.getCurrentBusinessDate();
            if(!ldt.isEqual(dt.toLocalDate())) {
                tradingSession = getTradingSessionOnOrAfter(ldt.toDateTime(dt.toLocalTime()));
                if(tradingSession.day() < dt.getDayOfWeek()) {
                    dt = dt.plusDays((DateTimeConstants.SUNDAY - dt.getDayOfWeek()) + 1);
                }
                dt = dt.withDayOfWeek(tradingSession.day());
                LocalTime lt = tradingSession.start();
                dt = dt.withHourOfDay(lt.getHourOfDay()).withMinuteOfHour(lt.getMinuteOfHour()).withSecondOfMinute(0);
            }
        }
        return dt;
    }
View Full Code Here

Examples of org.joda.time.LocalTime

        
        TradingWeek tradingWeek = new TradingWeek(ww.getWorkingDays());
        for(int i = 0;i < days.length;i++) {
            int day = days[i];
            tradingWeek.addTradingSession(new TradingSession(day, day,
                new LocalTime(8, 30, 0, 0), new LocalTime(15, 30, 0, 0)));
        }
       
        return tradingWeek;
    }
View Full Code Here

Examples of org.joda.time.LocalTime

                    Integer.parseInt(start[2].trim()), Integer.parseInt(start[3].trim()) };
            int[] endInts = new int[] {
                Integer.parseInt(end[0].trim()), Integer.parseInt(end[1].trim()),
                    Integer.parseInt(end[2].trim()), Integer.parseInt(end[3].trim()) };
            TradingSession session = new TradingSession(beginDay, endDay,
                new LocalTime(startInts[0], startInts[1], startInts[2], startInts[3]),
                    new LocalTime(endInts[0], endInts[1], endInts[2], endInts[3]));
           
            sessions.add(session);
        }
View Full Code Here

Examples of org.joda.time.LocalTime

  private static final DateTimeFormatter DEFAULT_FORMATTER = DateTimeFormat.forPattern(DEFAULT_FORMAT_STRING);
  private final LocalTime time;

  public TimeDatum(long value) {
    super(TajoDataTypes.Type.TIME);
    time = new LocalTime(value);
  }
View Full Code Here

Examples of org.joda.time.LocalTime

    time = new LocalTime(value);
  }

  public TimeDatum(int hour, int minute, int second) {
    super(TajoDataTypes.Type.TIME);
    time = new LocalTime(hour, minute, second);
  }
View Full Code Here

Examples of org.joda.time.LocalTime

    time = new LocalTime(hour, minute, second);
  }

  public TimeDatum(int hour, int minute, int second, int millis) {
    super(TajoDataTypes.Type.TIME);
    time = new LocalTime(hour, minute, second, millis);
  }
View Full Code Here

Examples of org.joda.time.LocalTime

            if (intradayDataJson.has(DATASET_KEY)) {
                JSONArray intradayDataArray = intradayDataJson.getJSONArray(DATASET_KEY);
                for (int i=0; i<intradayDataArray.size(); i++) {
                    JSONObject intradayDataRecord = intradayDataArray.getJSONObject(i);
                    String time = intradayDataRecord.getString("time") + "Z";
                    final LocalTime localTime = ISODateTimeFormat.timeNoMillis().parseLocalTime(time);
                    final long timeGmt = (midnight + localTime.getMillisOfDay())/1000;
                    int value = intradayDataRecord.getInt("value");
                    List<Object> record = new ArrayList<Object>();
                    record.add(timeGmt);
                    record.add(value);
                    if (metric.equals("calories")) {
View Full Code Here

Examples of org.joda.time.LocalTime

    }

    @JsonIgnore
    public static Duration getDifference(LocalTime departure, LocalTime arrival) {
        if ( departure.isAfter(arrival) ) {
            return Minutes.minutesBetween(departure, new LocalTime(23, 59)).plus(1).plus(Minutes.minutesBetween(LocalTime.MIDNIGHT, arrival)).toStandardDuration();
        } else {
            return Minutes.minutesBetween(departure, arrival).toStandardDuration();
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.