Get the amount of fractional units from the specified time instant.

@param instant  the milliseconds from 1970-01-01T00:00:00Z to query
@return the amount of fractional units extracted from the input.
978679
public int get(long instant) {
        if (instant >= 0) {
            return (int) ((instant / getUnitMillis()) % iRange);
        } else {
            return iRange - 1 + (int) (((instant + 1) / getUnitMillis()) % iRange);
        }
    }
526467
private String format(final Instant instant) {
		synchronized (formatter) {
			if (!instant.equals(lastInstant)) {
				lastInstant = instant;
				lastFormat = formatter.format(instant);
			}
			return lastFormat;
		}
	}
548780
public long get(final TimeUnit toUnit)
	{
		if (this.unit == toUnit)
			return period;
		else
			return toUnit.convert(period, this.unit);
	}
1000658
public static String secondsToUnits(int seconds, String unit) {
       if (unit == null) return String.valueOf(seconds);
       else if (unit.equals(INTERVAL_DAYS)) return String.valueOf(Math.round(seconds/86400));
       else if (unit.equals(INTERVAL_HOURS)) return String.valueOf(Math.round(seconds/3600));
       else if (unit.equals(INTERVAL_MINUTES)) return String.valueOf(Math.round(seconds/60));
       else  return String.valueOf(seconds);
   }
449776
public long getDurationMillis(Object object) {
        // parse here because duration could be bigger than the int supported
        // by the period parser
        String original = (String) object;
        String str = original;
        int len = str.length();
        if (len >= 4 &&
            (str.charAt(0) == 'P' || str.charAt(0) == 'p') &&
            (str.charAt(1) == 'T' || str.charAt(1) == 't') &&
            (str.charAt(len - 1) == 'S' || str.charAt(len - 1) == 's')) {
            // ok
        } else {
            throw new IllegalArgumentException("Invalid format: \"" + original + '"');
        }
        str = str.substring(2, len - 1);
        int dot = -1;
        boolean negative = false;
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) >= '0' && str.charAt(i) <= '9') {
                // ok
            } else if (i == 0 && str.charAt(0) == '-') {
                // ok
                negative = true;
            } else if (i > (negative ? 1 : 0) && str.charAt(i) == '.' && dot == -1) {
                // ok
                dot = i;
            } else {
                throw new IllegalArgumentException("Invalid format: \"" + original + '"');
            }
        }
        long millis = 0, seconds = 0;
        int firstDigit = negative ? 1 : 0;
        if (dot > 0) {
            seconds = Long.parseLong(str.substring(firstDigit, dot));
            str = str.substring(dot + 1);
            if (str.length() != 3) {
                str = (str + "000").substring(0, 3);
            }
            millis = Integer.parseInt(str);
        } else if (negative) {
            seconds = Long.parseLong(str.substring(firstDigit, str.length()));
        } else {
            seconds = Long.parseLong(str);
        }
        if (negative) {
            return FieldUtils.safeAdd(FieldUtils.safeMultiply(-seconds, 1000), -millis);
        } else {
            return FieldUtils.safeAdd(FieldUtils.safeMultiply(seconds, 1000), millis);
        }
    }
935521
private static final double printDurationFractionsOfMinutes(Duration duration, int factor)
   {
      double result = 0;

      if (duration != null)
      {
         result = duration.getDuration();

         switch (duration.getUnits())
         {
            case HOURS:
            case ELAPSED_HOURS:
            {
               result *= 60;
               break;
            }

            case DAYS:
            {
               result *= (60 * 8);
               break;
            }

            case ELAPSED_DAYS:
            {
               result *= (60 * 24);
               break;
            }

            case WEEKS:
            {
               result *= (60 * 8 * 5);
               break;
            }

            case ELAPSED_WEEKS:
            {
               result *= (60 * 24 * 7);
               break;
            }

            case MONTHS:
            {
               result *= (60 * 8 * 5 * 4);
               break;
            }

            case ELAPSED_MONTHS:
            {
               result *= (60 * 24 * 30);
               break;
            }

            case YEARS:
            {
               result *= (60 * 8 * 5 * 52);
               break;
            }

            case ELAPSED_YEARS:
            {
               result *= (60 * 24 * 365);
               break;
            }

            default:
            {
               break;
            }
         }
      }

      result *= factor;

      return (result);
   }
416475
private static Integer getMinuteUtc(AisExtractor extractor,
			int slotTimeout, int startIndex) {
		if (slotTimeout == 1) {
			// skip the msb bit
			int minutes = extractor.getValue(startIndex + 10, startIndex + 17);
			return minutes;
		} else
			return null;
	}
1367396
public Instant getNextExecutionTimeAfter(Instant now) {
        OffsetTime timeOfDay = OffsetTime.from(TIME_OF_DAY_FORMAT.parse(getTimeOfDay()));

        // The time of the next run is based on the time past midnight UTC relative to the current time
        Instant nextExecTime = now.atOffset(ZoneOffset.UTC).with(timeOfDay).toInstant();

        // If the first execution would have been for earlier today move to the next execution.
        while (nextExecTime.isBefore(now)) {
            nextExecTime = nextExecTime.plus(Duration.ofDays(1));
        }

        return nextExecTime;
    }
1162798
public static Instant convertDotNetTicksToInstant(long dotNetTicks)
	{
		long ticksFromEpoch = dotNetTicks - EPOCHINDOTNETTICKS;
		long millisecondsFromEpoch = ticksFromEpoch/10000;
		long fractionTicks = ticksFromEpoch%10000;
		return Instant.ofEpochMilli(millisecondsFromEpoch).plusNanos(fractionTicks*100);
	}
783046
public long getCount(long toWhen, long period, TimeUnit unit) {
		return getCount(toWhen - TimeUnit.MILLISECONDS.convert(period, unit), toWhen);
	}
1164576
public long subtract(long instant, int value) {
        if (value == Integer.MIN_VALUE) {
            return subtract(instant, (long) value);
        }
        return add(instant, -value);
    }
1167925
@Pure
	public static double fromMetersPerSecond(double value, SpeedUnit outputUnit) {
		switch (outputUnit) {
		case KILOMETERS_PER_HOUR:
			return value / 3.6;
		case MILLIMETERS_PER_SECOND:
			return value * 1000.;
		case METERS_PER_SECOND:
		default:
		}
		return value;
	}
471901
public Long getUnixTimeMillis() {
        String time = tags.get("c");
        if (time == null)
            return null;
        else
            try {
                return Long.parseLong(time) * 1000;
            } catch (NumberFormatException e) {
                return null;
            }
    }
774115
@Pure
	public static double toMetersPerSecond(double value, SpeedUnit inputUnit) {
		switch (inputUnit) {
		case KILOMETERS_PER_HOUR:
			return 3.6 * value;
		case MILLIMETERS_PER_SECOND:
			return value / 1000.;
		case METERS_PER_SECOND:
		default:
		}
		return value;
	}
444434
public long currentTimeInMillis() {

        if (this.monotonic || MONOTON_MODE) {
            long nanos = this.utcNanos();
            long secs = LeapSeconds.getInstance().strip(Math.floorDiv(nanos, MRD));
            return Math.multiplyExact(secs, 1000) + Math.floorMod(nanos, MIO);
        } else {
            return System.currentTimeMillis();
        }

    }
468335
public long roundFloor(long instant) {
        if (instant >= 0) {
            return instant - instant % iUnitMillis;
        } else {
            instant += 1;
            return instant - instant % iUnitMillis - iUnitMillis;
        }
    }
936975
public double getAverageRequestDuration(String intervalName, TimeUnit unit) {
		return unit.transformNanos(totalTime.getValueAsLong(intervalName)) / totalRequests.getValueAsDouble(intervalName);
	}