Example usage for org.joda.time LocalTime equals

List of usage examples for org.joda.time LocalTime equals

Introduction

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

Prototype

public boolean equals(Object partial) 

Source Link

Document

Compares this ReadablePartial with another returning true if the chronology, field types and values are equal.

Usage

From source file:dk.teachus.backend.domain.impl.PeriodImpl.java

License:Apache License

public boolean mayBook(LocalTime time) {
    boolean mayBook = false;

    if (isTimeValid(time)) {
        time = time.plusMinutes(lessonDuration);
        if (time.equals(endTime) || time.isBefore(endTime)) {
            mayBook = true;/* w  w w. j a  va 2 s .c o  m*/
        }
    }

    return mayBook;
}

From source file:graphene.util.time.JodaTimeUtil.java

License:Apache License

public static void test_localTime_as_integer() {
    System.out.println("Test LocalTime as Integer");
    final LocalTime lt1 = new LocalTime();
    final Integer i = toIntegerMillis(lt1);
    final LocalTime lt2 = toLocalTime(i);
    System.out.println("LocalTime 1 = " + lt1);
    System.out.println("Integer     = " + i);
    System.out.println("LocalTime 2 = " + lt2);
    if (!lt2.equals(lt1)) {
        throw new IllegalStateException();
    }/*from   w ww  .  j av a2  s  .  c om*/
}

From source file:graphene.util.time.JodaTimeUtil.java

License:Apache License

public static void test_localTime_as_string() {
    System.out.println("Test LocalTime as String");
    final LocalTime lt1 = new LocalTime();
    final String t = toString(lt1);
    final LocalTime lt2 = toLocalTime(t);
    System.out.println("LocalTime 1 = " + lt1);
    System.out.println("String      = " + t);
    System.out.println("LocalTime 2 = " + lt2);
    if (!lt2.equals(lt1)) {
        throw new IllegalStateException();
    }/*from w  ww  .j  av a  2s  . c  o m*/
}

From source file:lt.norma.crossbow.contracts.Exchange.java

License:Open Source License

/**
 * Constructor.//from  www .  j  a v  a  2  s  . c  o m
 * 
 * @param name
 *           name of the exchange
 * @param tradingStarts
 *           beginning of trading day
 * @param tradingEnds
 *           end of trading day
 * @param timeZone
 *           time zone at the exchange
 */
public Exchange(String name, DateTimeZone timeZone, LocalTime tradingStarts, LocalTime tradingEnds) {
    // Data control
    if (name == null) {
        throw new InvalidArgumentRuntimeException("name", "null");
    }
    if (name == null || name.length() < 1) {
        throw new InvalidArgumentRuntimeException("name", "");
    }
    if (timeZone == null) {
        throw new InvalidArgumentRuntimeException("timeZone", "null");
    }
    if (tradingStarts == null) {
        throw new InvalidArgumentRuntimeException("tradingStarts", "null");
    }
    if (tradingEnds == null) {
        throw new InvalidArgumentRuntimeException("tradingEnds", "null");
    }

    this.name = name;
    this.timeZone = timeZone;
    this.tradingStarts = tradingStarts;
    this.tradingEnds = tradingEnds;
    doesClose = !tradingEnds.equals(new LocalTime(0, 0, 0));
}

From source file:org.apereo.portal.events.aggr.PortalEventDimensionPopulatorImpl.java

License:Apache License

/** Populate the time dimensions */
final void doPopulateTimeDimensions() {
    final List<TimeDimension> timeDimensions = this.timeDimensionDao.getTimeDimensions();
    if (timeDimensions.isEmpty()) {
        logger.info("No TimeDimensions exist, creating them");
    } else if (timeDimensions.size() != (24 * 60)) {
        this.logger.info(
                "There are only " + timeDimensions.size() + " time dimensions in the database, there should be "
                        + (24 * 60) + " creating missing dimensions");
    } else {//  w w w  .j a v a 2 s  .  c  om
        this.logger.debug("Found expected " + timeDimensions.size() + " time dimensions");
        return;
    }

    LocalTime nextTime = new LocalTime(0, 0);
    final LocalTime lastTime = new LocalTime(23, 59);

    for (final TimeDimension timeDimension : timeDimensions) {
        LocalTime dimensionTime = timeDimension.getTime();
        if (nextTime.isBefore(dimensionTime)) {
            do {
                checkShutdown();
                this.timeDimensionDao.createTimeDimension(nextTime);
                nextTime = nextTime.plusMinutes(1);
            } while (nextTime.isBefore(dimensionTime));
        } else if (nextTime.isAfter(dimensionTime)) {
            do {
                checkShutdown();
                this.timeDimensionDao.createTimeDimension(dimensionTime);
                dimensionTime = dimensionTime.plusMinutes(1);
            } while (nextTime.isAfter(dimensionTime));
        }

        nextTime = dimensionTime.plusMinutes(1);
    }

    //Add any missing times from the tail
    while (nextTime.isBefore(lastTime) || nextTime.equals(lastTime)) {
        checkShutdown();
        this.timeDimensionDao.createTimeDimension(nextTime);
        if (nextTime.equals(lastTime)) {
            break;
        }
        nextTime = nextTime.plusMinutes(1);
    }
}

From source file:org.jasig.portal.events.aggr.PortalEventAggregationManagerImpl.java

License:Apache License

/**
 * Populate the time dimensions //from   ww  w .  j a  v  a2s.  c  om
 */
void doPopulateTimeDimensions() {
    final List<TimeDimension> timeDimensions = this.timeDimensionDao.getTimeDimensions();
    if (timeDimensions.isEmpty()) {
        logger.info("No TimeDimensions exist, creating them");
    } else if (timeDimensions.size() != (24 * 60)) {
        this.logger.info(
                "There are only " + timeDimensions.size() + " time dimensions in the database, there should be "
                        + (24 * 60) + " creating missing dimensions");
    } else {
        this.logger.debug("Found expected " + timeDimensions.size() + " time dimensions");
        return;
    }

    LocalTime nextTime = new LocalTime(0, 0);
    final LocalTime lastTime = new LocalTime(23, 59);

    for (final TimeDimension timeDimension : timeDimensions) {
        LocalTime dimensionTime = timeDimension.getTime();
        if (nextTime.isBefore(dimensionTime)) {
            do {
                this.timeDimensionDao.createTimeDimension(nextTime);
                nextTime = nextTime.plusMinutes(1);
            } while (nextTime.isBefore(dimensionTime));
        } else if (nextTime.isAfter(dimensionTime)) {
            do {
                this.timeDimensionDao.createTimeDimension(dimensionTime);
                dimensionTime = dimensionTime.plusMinutes(1);
            } while (nextTime.isAfter(dimensionTime));
        }

        nextTime = dimensionTime.plusMinutes(1);
    }

    //Add any missing times from the tail
    while (nextTime.isBefore(lastTime) || nextTime.equals(lastTime)) {
        this.timeDimensionDao.createTimeDimension(nextTime);
        if (nextTime.equals(lastTime)) {
            break;
        }
        nextTime = nextTime.plusMinutes(1);
    }
}