Examples of Hour


Examples of org.jfree.data.time.Hour

    /**
     * The {@link Hour} class is immutable, so should not be {@link Cloneable}.
     */
    public void testNotCloneable() {
        Hour h = new Hour(7, 9, 10, 1999);
        assertFalse(h instanceof Cloneable);
    }
View Full Code Here

Examples of org.jfree.data.time.Hour

    public void testGetFirstMillisecond() {
        Locale saved = Locale.getDefault();
        Locale.setDefault(Locale.UK);
        TimeZone savedZone = TimeZone.getDefault();
        TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
        Hour h = new Hour(15, 1, 4, 2006);
        assertEquals(1143900000000L, h.getFirstMillisecond());
        Locale.setDefault(saved);
        TimeZone.setDefault(savedZone);
    }
View Full Code Here

Examples of org.jfree.data.time.Hour

    /**
     * Some checks for the getFirstMillisecond(TimeZone) method.
     */
    public void testGetFirstMillisecondWithTimeZone() {
        Hour h = new Hour(15, 1, 4, 1950);
        TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
        assertEquals(-623293200000L, h.getFirstMillisecond(zone));

        // try null calendar
        boolean pass = false;
        try {
            h.getFirstMillisecond((TimeZone) null);
        }
        catch (NullPointerException e) {
            pass = true;
        }
        assertTrue(pass);
View Full Code Here

Examples of org.jfree.data.time.Hour

    /**
     * Some checks for the getFirstMillisecond(TimeZone) method.
     */
    public void testGetFirstMillisecondWithCalendar() {
        Hour h = new Hour(2, 15, 4, 2000);
        GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY);
        calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt"));
        assertEquals(955764000000L, h.getFirstMillisecond(calendar));

        // try null calendar
        boolean pass = false;
        try {
            h.getFirstMillisecond((Calendar) null);
        }
        catch (NullPointerException e) {
            pass = true;
        }
        assertTrue(pass);
View Full Code Here

Examples of org.ocpsoft.prettytime.units.Hour

   {
      addUnit(new JustNow());
      addUnit(new Millisecond());
      addUnit(new Second());
      addUnit(new Minute());
      addUnit(new Hour());
      addUnit(new Day());
      addUnit(new Week());
      addUnit(new Month());
      addUnit(new Year());
      addUnit(new Decade());
View Full Code Here

Examples of web.rechelper.Hour

        //Создаем таблицу часы минуты
        ArrayList<Hour> hours = new ArrayList<Hour>();
        List<Ticket> tickets = weekDay.getTickets();
        for (int i = 0; i < 23; i++) {
            hours.add(new Hour(i));
        }

        if (tickets != null && tickets.size() > 0) {
            //распределяем тикеты по часам
            for (int i = 0; i < tickets.size(); i++) {
                Ticket ticket = tickets.get(i);
                ticket.setHeight(ticket.getDuration());
                int mm = ticket.getMinute();
                int hh = ticket.getHour();
                int duration = ticket.getHeight();

                while (duration > 0) {
                    if (mm + duration <= 60) {
                        ticket.setHeight(duration);
                        if (ticket.getHeight() >= 3) {
                            hours.get(hh).getTickets().add(ticket);
                        }
                        duration = 0;
                    } else {
                        ticket.setHeight(60-mm);
                        if (ticket.getHeight() >= 3) {
                            hours.get(hh).getTickets().add(ticket);
                        }
                        boolean buzy = ticket.isBuzy();
                        duration = duration - (60-mm);
                        ticket = new Ticket(ticket.getCalendar(), ticket.getDuration());
                        ticket.setBuzy(buzy);
                        //переход на след. час
                        hh += 1;
                        mm = 0;
                    }
                }
            }

            //заполняем пустые места в часе
            for (Hour hour : hours) {
                ArrayList<Ticket> tList = hour.getTickets();
                ArrayList<Ticket> newTickets = new ArrayList<Ticket>();
                Collections.sort(tList);
                int lasttime = 0;
                for (Ticket ticket : tList) {
                    if (ticket.getHour() != hour.getHour()) {
                        Calendar cal = (Calendar) ticket.getCalendar().clone();
                        cal.add(Calendar.MINUTE, ticket.getDuration());
                        lasttime = cal.get(Calendar.MINUTE);
                    }
                    else if (ticket.getMinute() > lasttime) {
                        int height = ticket.getMinute()-lasttime;
                        Calendar cal = (Calendar) ticket.getCalendar().clone();
                        cal.add(Calendar.MINUTE, -height);
                        cal.set(Calendar.HOUR_OF_DAY, hour.getHour());
                        Ticket newTicket = new Ticket(cal, height);
                        newTicket.setHeight(height);
                        newTicket.setBuzy(true);
                        if (newTicket.getHeight() >= 3) {
                            newTickets.add(newTicket);
                        }
                    }
                    lasttime = ticket.getMinute()+ ticket.getDuration();
                }
                if (lasttime < 60) {
                    Calendar cal = weekDay.getDay().getCalendar();
                    cal.set(Calendar.HOUR_OF_DAY, hour.getHour());
                    cal.set(Calendar.MINUTE, lasttime);
                    cal.set(Calendar.SECOND, 0);
                    cal.set(Calendar.MILLISECOND, 0);
                    Ticket newTicket = new Ticket(cal, 60 - lasttime);
                    newTicket.setHeight(60 - lasttime);
                    newTicket.setBuzy(true);
                    if (newTicket.getHeight() >= 3) {
                        newTickets.add(newTicket);
                    }
                }
                tList.addAll(newTickets);
                Collections.sort(tList);
            }

        }
        //Удаляем пустые часы за рамками интервала
        for (Iterator<Hour> it = hours.iterator(); it.hasNext();) {
            Hour hour = it.next();
            if (hour.getHour() < 8 || hour.getHour() > 18) {
                boolean empty = true;
                for (Ticket ticket : hour.getTickets()) {
                    if (!ticket.isBuzy()) {
                        empty = false;
                    }
                }
                if (empty) {
                    it.remove();
                }
            }
        }
        //если часов больше 11 то удаляем пустые начиная с конца
        for (int i = hours.size() - 1; i >=0; i--) {
            Hour hour = hours.get(i);
                boolean empty = true;
                for (Ticket ticket : hour.getTickets()) {
                    if (!ticket.isBuzy()) {
                        empty = false;
                    }
                }
                if (empty && hours.size() > 11) {
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.