deconstruct-number-format

WebJar for deconstruct-number-format

License

License

MIT
Categories

Categories

ORM Data
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

deconstruct-number-format
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

deconstruct-number-format
WebJar for deconstruct-number-format
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/DeeLindesay/deconstruct-number-format

Download deconstruct-number-format

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/deconstruct-number-format/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>deconstruct-number-format</artifactId>
    <version>0.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/deconstruct-number-format/
implementation 'org.webjars.npm:deconstruct-number-format:0.0.1'
// https://jarcasting.com/artifacts/org.webjars.npm/deconstruct-number-format/
implementation ("org.webjars.npm:deconstruct-number-format:0.0.1")
'org.webjars.npm:deconstruct-number-format:jar:0.0.1'
<dependency org="org.webjars.npm" name="deconstruct-number-format" rev="0.0.1">
  <artifact name="deconstruct-number-format" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='deconstruct-number-format', version='0.0.1')
)
libraryDependencies += "org.webjars.npm" % "deconstruct-number-format" % "0.0.1"
[org.webjars.npm/deconstruct-number-format "0.0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

deconstruct-number-format

To deconstruct a number format eg '-£#,##0.##0 /m', '(33 years)', '$ -99.00' and return a set of parameters to describe the format.

Accepts:

  • negative signs before or after prefix text
  • brackets as negative signs
  • prefix and suffix texts
  • . or , as decimal point
  • space or . or , as thousand separators
  • space or . or , as thousanths separators
  • #, 9 or 0 as number place holders

Returns:

  • negativeType: 'right', 'left', 'brackets', 'none'
  • negativeRightPos: 0 if right negative or bracket is at end of expression, >0 if right/bracket is followed by suffix; -1 no right negative
  • negativeLeftPos: 0 if right negative or bracket is at start expression, >0 if right/bracket follows prefix; -1 no left negative
  • suffix: text characters after number; can be ''
  • prefix: text characters before number (cannot include 0,9,#); can be ''
  • negativeLeftSymbol: left hand negative symbol (may include trailing spaces), eg '(', '( ', '- '
  • negativeRightSymbol: right hand negative symbol (may include leading spaces), eg ')', ' )', ' -'
  • decimalChar: character repesenting decimal (. or ,)
  • integerSeparator: separator of thousands (space or . or ,); empty string if no separator
  • decimalsSeparator: separator of thousanths (space or . or ,); empty string if no separator
  • padLeft: padding front of number, based on first postition of a zero; -1 = no padding
  • maxLeft: max places permitted before the dp, based on 9 or 0 as the first number holder; -1 = no max
  • padRight: zero padding required to right of dp, based on last postition of a zero; -1 = no padding
  • maxRight: max places permitted after the dp, based on 0 or 9 as the last number holder, can be 0 (integer only); -1 = no max

Notes on decimal points/thousands separators:

If a format ends in a . or , then this will be taken as the decimal character UNLESS the same character is used elsewhere so:

  • #,###. results in decimalChar = '.', thousands separator = ','
  • #.###, results in decimalChar = ',', thousands separator = '.'

If a format only has one of ',' or '.' and the character only appears once it is taken as the decimal point

  • #,### results in decimalChar = ','
  • #.### results in decimalChar = '.'

If the character appears twice it is a separator

  • #,###,### results in decimalChar = '.', thousands separator = ','
  • #.###.### results in decimalChar = ',', thousands separator = '.'

When in doubt '.' is taken as the separator, so

  • #.###,# results in decimalChar = '.', thousandths separator = ',' To create the same structure with decimalChar as ',', just add a '.' at start or end or extend expression eg
  • .#.###,#
  • #.###,#.
  • #.###.###,#

Does not work for:

  • structured reference numbers, eg 9999-9999
  • ignores and removes leading and trailing spaces (but retains those between pre/post fix and negative symbols etc)

Versions

Version
0.0.1