Stay organized with collections Save and categorize content based on your preferences.

public class Scale
extends Object



A class that defines a quantity by which a number should be multiplied when formatting.

To create a Multiplier, use one of the factory methods.

Summary

Public methods

static Scale byBigDecimal(BigDecimal multiplicand)

Multiply numbers by an arbitrary value before formatting.

static Scale byDouble(double multiplicand)

Multiply numbers by an arbitrary value before formatting.

static Scale byDoubleAndPowerOfTen(double multiplicand, int power)

Multiply a number by both a power of ten and by an arbitrary double value before formatting.

static Scale none()

Do not change the value of numbers when formatting or parsing.

static Scale powerOfTen(int power)

Multiply numbers by 100 before formatting.

Inherited methods

From class java.lang.Object

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public methods

byBigDecimal

public static Scale byBigDecimal (BigDecimal multiplicand)

Multiply numbers by an arbitrary value before formatting. Useful for unit conversions.

This method takes a BigDecimal; also see the version that takes a double.

Parameters
multiplicand BigDecimal
Returns
Scale A Multiplier for passing to the setter in NumberFormatter.

byDouble

public static Scale byDouble (double multiplicand)

Multiply numbers by an arbitrary value before formatting. Useful for unit conversions.

This method takes a double; also see the version that takes a BigDecimal.

Parameters
multiplicand double
Returns
Scale A Multiplier for passing to the setter in NumberFormatter.

byDoubleAndPowerOfTen

public static Scale byDoubleAndPowerOfTen (double multiplicand, 
                int power)

Multiply a number by both a power of ten and by an arbitrary double value before formatting.

Parameters
multiplicand double
power int
Returns
Scale A Multiplier for passing to the setter in NumberFormatter.

none

public static Scale none ()

Do not change the value of numbers when formatting or parsing.

Returns
Scale A Multiplier to prevent any multiplication.

powerOfTen

public static Scale powerOfTen (int power)

Multiply numbers by 100 before formatting. Useful for combining with a percent unit:

 NumberFormatter.with().unit(NoUnit.PERCENT).multiplier(Multiplier.powerOfTen(2))
 
Parameters
power int
Returns
Scale A Multiplier for passing to the setter in NumberFormatter.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2023-02-08 UTC.