Java Time Format formatMeasures(final int quartersPerMeasure, final double time, final int startOffset)

Here you can find the source of formatMeasures(final int quartersPerMeasure, final double time, final int startOffset)

Description

Format the given time as measure.quarters.eights.

License

LGPL

Parameter

Parameter Description
quartersPerMeasure The number of quarters of a measure
time The time to format
startOffset An offset that is added to the measure, quarter and eights values

Return

The formatted text

Declaration

public static String formatMeasures(final int quartersPerMeasure, final double time, final int startOffset) 

Method Source Code

//package com.java2s;
// Licensed under LGPLv3 - http://www.gnu.org/licenses/lgpl-3.0.txt

public class Main {
    /**//from  w  ww  .ja  v  a  2 s.c  o  m
     * Format the given time as measure.quarters.eights.
     *
     * @param quartersPerMeasure The number of quarters of a measure
     * @param time The time to format
     * @param startOffset An offset that is added to the measure, quarter and eights values
     * @return The formatted text
     */
    public static String formatMeasures(final int quartersPerMeasure, final double time, final int startOffset) {
        final int measure = (int) Math.floor(time / quartersPerMeasure);
        double t = time - measure * quartersPerMeasure;
        final int quarters = (int) Math.floor(t); // :1
        t = t - quarters; // *1
        final int eights = (int) Math.floor(t / 0.25);
        return measure + startOffset + "." + (quarters + startOffset) + "." + (eights + startOffset);
    }
}

Related

  1. formatElapsedTime(long time)
  2. formatEndRowKeyString(String id, String timestampEnd)
  3. formatExecutionTime(long executionTime)
  4. formatExecutionTime(long ms)
  5. formatInformalTime(final String minuteRoundedName, final String minuteRoundingToken, final String informalHourName)
  6. formatMicroSpan(long time)
  7. formatMili(long timeDelta)
  8. formatMs(long elapsedTime)
  9. formatMusicTime(int time)