Example usage for java.lang Math floorMod

List of usage examples for java.lang Math floorMod

Introduction

In this page you can find the example usage for java.lang Math floorMod.

Prototype

public static long floorMod(long x, long y) 

Source Link

Document

Returns the floor modulus of the long arguments.

Usage

From source file:Main.java

public static int getOddOrEvent(int groupId) {
    //int groupId   =   5;
    int remainder = Math.floorMod(groupId, 2);

    return remainder;

}

From source file:com.nridge.core.base.std.DatUtl.java

/**
 * Calculates the number of business days (excluding weekends)
 * between two dates (inclusive)./*from  w w w  .ja va2 s  .com*/
 * <p>
 * https://stackoverflow.com/questions/4600034/calculate-number-of-weekdays-between-two-dates-in-java
 * </p>
 * @param aStartDate Start date.
 * @param anEndDate End date.
 *
 * @return Number of business days.
 */
@SuppressWarnings("UnnecessaryLocalVariable")
public static long calculateBusinessDays(LocalDate aStartDate, LocalDate anEndDate) {
    DayOfWeek startWeekDay = aStartDate.getDayOfWeek().getValue() < 6 ? aStartDate.getDayOfWeek()
            : DayOfWeek.MONDAY;
    DayOfWeek endWeekDay = anEndDate.getDayOfWeek().getValue() < 6 ? anEndDate.getDayOfWeek()
            : DayOfWeek.FRIDAY;

    long numberOfWeeks = ChronoUnit.DAYS.between(aStartDate, anEndDate) / 7;
    long totalWeekDays = numberOfWeeks * 5 + Math.floorMod(endWeekDay.getValue() - startWeekDay.getValue(), 5);

    return totalWeekDays + 1;
}

From source file:org.janusgraph.diskstorage.solr.SolrIndex.java

private Object convertValue(Object value) throws BackendException {
    if (value instanceof Geoshape) {
        return GeoToWktConverter.convertToWktString((Geoshape) value);
    }//from ww w .  j  av  a  2 s . c o  m
    if (value instanceof UUID) {
        return value.toString();
    }
    if (value instanceof Instant) {
        if (Math.floorMod(((Instant) value).getNano(), 1000000) != 0) {
            throw new IllegalArgumentException("Solr indexes do not support nanoseconds");
        }
        return new Date(((Instant) value).toEpochMilli());
    }
    return value;
}