java.lang.Object
com.bonitasoft.processbuilder.extension.Utils

public final class Utils extends Object
Utility class providing common String manipulation methods, focusing on normalization and case formatting.

This class is designed to be non-instantiable and should only be accessed via static methods.

Since:
1.0
Author:
Bonitasoft
  • Method Summary

    Modifier and Type
    Method
    Description
    static long
    calculateElapsedTime(long startTime)
    Calculates the elapsed time from a given start point up to the current moment.
    static long
    calculateElapsedTime(long startTime, long endTime)
    Calculates the elapsed time between two given time points.
    static long
    extractMilliseconds(long elapsedTimeMillis)
    Extracts the milliseconds component (0-999) from an elapsed time.
    static long
    extractMinutes(long elapsedTimeMillis)
    Extracts the minutes component from an elapsed time in milliseconds.
    static long
    extractSeconds(long elapsedTimeMillis)
    Extracts the seconds component (0-59) from an elapsed time in milliseconds.
    static String
    formatElapsedTime(long elapsedTime)
    Formats elapsed time as a human-readable string with minutes, seconds, and milliseconds.
    static long
    logAndGetElapsedTime(long startTime, String name)
    Calculates and logs the elapsed time from a given start point up to the current moment.
    static void
    logElapsedTime(long startTime, String name)
    Calculates and logs the elapsed time from a given start point up to the moment of the call.
    static void
    logElapsedTimeByElapsedTime(long elapsedTime, String name)
    Logs the given elapsed time, formatted as minutes, seconds, and milliseconds.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • logElapsedTime

      public static void logElapsedTime(long startTime, String name)
      Calculates and logs the elapsed time from a given start point up to the moment of the call.

      The total execution time (the difference between the current time and startTime) is broken down and displayed in minutes, seconds, and milliseconds via the log at the INFO level.

      Parameters:
      startTime - The initial time in milliseconds (typically obtained using System.currentTimeMillis()) from which the duration is calculated.
      name - A descriptive identifier or name of the operation/task for which the time is being measured (used within the log message).
      See Also:
    • calculateElapsedTime

      public static long calculateElapsedTime(long startTime)
      Calculates the elapsed time from a given start point up to the current moment.

      This method provides a simple way to measure execution duration by comparing the provided start time with the current system time.

      Parameters:
      startTime - The initial time in milliseconds (typically obtained using System.currentTimeMillis()) from which the duration is calculated.
      Returns:
      The elapsed time in milliseconds.
      See Also:
    • calculateElapsedTime

      public static long calculateElapsedTime(long startTime, long endTime)
      Calculates the elapsed time between two given time points.

      This method computes the difference between the end time and start time, returning the result in milliseconds.

      Parameters:
      startTime - The initial time in milliseconds (typically obtained using System.currentTimeMillis()).
      endTime - The final time in milliseconds (typically obtained using System.currentTimeMillis()).
      Returns:
      The elapsed time in milliseconds (endTime - startTime).
      See Also:
    • logElapsedTimeByElapsedTime

      public static void logElapsedTimeByElapsedTime(long elapsedTime, String name)
      Logs the given elapsed time, formatted as minutes, seconds, and milliseconds.

      This method is useful when the elapsed time has already been calculated and only needs to be logged with a descriptive name.

      Parameters:
      elapsedTime - The pre-calculated elapsed time in milliseconds.
      name - A descriptive identifier or name of the operation/task for which the time was measured (used within the log message).
    • formatElapsedTime

      public static String formatElapsedTime(long elapsedTime)
      Formats elapsed time as a human-readable string with minutes, seconds, and milliseconds.

      This method extracts the time components and formats them in a consistent pattern.

      Parameters:
      elapsedTime - The elapsed time in milliseconds.
      Returns:
      A formatted string in the pattern "Xm Ys Zms".
    • extractMinutes

      public static long extractMinutes(long elapsedTimeMillis)
      Extracts the minutes component from an elapsed time in milliseconds.
      Parameters:
      elapsedTimeMillis - The elapsed time in milliseconds.
      Returns:
      The number of complete minutes.
    • extractSeconds

      public static long extractSeconds(long elapsedTimeMillis)
      Extracts the seconds component (0-59) from an elapsed time in milliseconds.

      This returns only the seconds portion after extracting complete minutes, using modulo 60 to ensure the result is within the 0-59 range.

      Parameters:
      elapsedTimeMillis - The elapsed time in milliseconds.
      Returns:
      The seconds component (0-59).
    • extractMilliseconds

      public static long extractMilliseconds(long elapsedTimeMillis)
      Extracts the milliseconds component (0-999) from an elapsed time.

      This returns only the milliseconds portion after extracting complete seconds, using modulo 1000 to ensure the result is within the 0-999 range.

      Parameters:
      elapsedTimeMillis - The elapsed time in milliseconds.
      Returns:
      The milliseconds component (0-999).
    • logAndGetElapsedTime

      public static long logAndGetElapsedTime(long startTime, String name)
      Calculates and logs the elapsed time from a given start point up to the current moment.

      This is a convenience method that combines calculateElapsedTime(long) and logElapsedTime(long, String) into a single call. The total execution time is broken down and displayed in minutes, seconds, and milliseconds via the log at the INFO level.

      Parameters:
      startTime - The initial time in milliseconds (typically obtained using System.currentTimeMillis()) from which the duration is calculated.
      name - A descriptive identifier or name of the operation/task for which the time is being measured (used within the log message).
      Returns:
      The elapsed time in milliseconds.
      See Also: