Package org.joda.time

Examples of org.joda.time.LocalTime


      return dt;
    }

    @Override
    protected String convertToString(Object value) {
      LocalTime dt = (LocalTime) value;
      return fmt.print(dt);
    }
View Full Code Here


import org.joda.time.LocalTime;

public class LocalTimePropertyEditor extends PropertyEditorSupport {
  public void setAsText(String text) throws IllegalArgumentException {
    setValue(new LocalTime(text));
  }
View Full Code Here

  {
    JodaTimeTranslators.add(fact());
    fact().register(HasJoda.class);

    HasJoda hj = new HasJoda();
    hj.localTime = new LocalTime();
    hj.localDate = new LocalDate();
    hj.localDateTime = new LocalDateTime();
    hj.dateTime = new DateTime();
    hj.dateTimeZone = DateTimeZone.forID("America/Los_Angeles");
    hj.yearMonth = new YearMonth();
View Full Code Here

        assertEquals(new LocalDate(2016, 1, 4, chrono), f.parseLocalDate("2016-01-01"));
    }

    //-----------------------------------------------------------------------
    public void testParseLocalTime_simple() {
        assertEquals(new LocalTime(10, 20, 30), g.parseLocalTime("2004-06-09T10:20:30Z"));
        assertEquals(new LocalTime(10, 20, 30), g.parseLocalTime("2004-06-09T10:20:30+18:00"));
        assertEquals(new LocalTime(10, 20, 30), g.parseLocalTime("2004-06-09T10:20:30-18:00"));
        assertEquals(new LocalTime(10, 20, 30, 0, BUDDHIST_PARIS),
                g.withChronology(BUDDHIST_PARIS).parseLocalTime("2004-06-09T10:20:30Z"));
        try {
            g.parseDateTime("ABC");
            fail();
        } catch (IllegalArgumentException ex) {}
View Full Code Here

   
    return formatter.format(Math.round(number * 100)) + "%";
  }
 
  public static String toTimeString(Integer seconds){
    return new LocalTime(0,
               seconds / 60,
               seconds % 60).toString("mm:ss");
  }
View Full Code Here

     * @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

        }
        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

                    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

        
        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

                    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

TOP

Related Classes of org.joda.time.LocalTime

Copyright © 2018 www.massapicom. 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.