Class Conventions
- All Implemented Interfaces:
Serializable
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DecimalFormatprotected DecimalFormatSymbolsprotected charprotected intprotected Stringprotected charprotected intprotected charprotected Stringprotected DecimalFormatprotected DecimalFormatSymbolsprotected charprotected intprotected Stringprotected Stringprotected Stringprotected charprotected intprotected charprotected charprotected SimpleDateFormatprotected SimpleDateFormatprotected Stringprotected Stringstatic final ConventionsA thread-safe Conventions object, with the standardCODING_FORMATstatic final StringDefines the standard coding formatprotected ConcurrentHashMap<Measure, MeasureWrapper> protected TeacherDutyprotected String -
Constructor Summary
ConstructorsConstructorDescriptionEmpty constructor, creates a thread-safe objectCopy Constructor -
Method Summary
Modifier and TypeMethodDescriptionConverts theEuroobject passed as parameter into a string, using the current correct DecimalFormat for currencies of the instancedate2String(Date d) Converts the Date passed as parameter into a string, using the current correct SimpleDateFormat of the instanceConverts the BigDecimal passed as parameter into a string, using the current correct DecimalFormat of the instancecharReturns the char that represents the decimal separator for the DecimalFormat used by this instance of Conventions to represents the currencies valuesintReturns the number of decimal digits (precision) for the DecimalFormat used by this instance of Conventions to represents the currencies valuesReturns the string that represents the DecimalFormat used by this instance of Conventions to represents the currencies valuescharReturns the char that represents the thousands separator for the DecimalFormat used by this instance of Conventions to represents the currencies valuesintReturns the number of the thousands grouping size for the DecimalFormat used by this instance of Conventions to represents the currencies valuescharReturns the char that represents the minus symbol for the DecimalFormat used by this instance of Conventions to represents the currencies valuesReturns the string that represents the currency symbol for the DecimalFormat used by thi instance of Conventions to represents the currencies valuescharReturns the char that represents the decimal separator for the DecimalFormat of this instance of ConventionsintReturns the number of decimal digits (precision) for the DecimalFormat of this instance of ConventionsgetDisplayUnit(Measure displayUnit) Retrieves the correctMeasureWrapperassociated (by the user's language preferences) to the displayUnit passed as parameter.
For example, if in the user's language preferences it's set that the kilometers must be shown as miles ( with $MEASURE_km=mi,2), so if the display unit passed as parameter represent the kilometers it will be returned theMeasureWrapperobject that represent the miles unit of measurement and its output decimal precision.Returns the string that represents the exponent symbol used by the DecimalFormat of this instance of ConventionsgetFdw()Returns the string that represents which is the day considered as first day of the weekReturns the string that represents the DecimalFormat used by this instance of Conventions for the format of numberscharReturns the char that represents the thousands separator for the DecimalFormat of this instance of ConventionsintReturns the number of the thousands grouping size for the DecimalFormat of this instance of ConventionscharReturns the char that represents the minus symbol for the DecimalFormat of this instance of ConventionscharReturns the char that represents the symbol used for the percentual numbers by the DecimalFormat of this instance of ConventionsReturns the string that represents the format used by this instance of Conventions for the format of Dates (read a Date and obtain a String).Returns the string that represents the format used by this instance of Conventions for the parsing of Dates (read a string and obtain a Date).Returns the string that represents which hour system will be used; 24h or 12hvoidsetCurrencyFormat(String format) Sets the string used to define the DecimalFormat used by this instance of Conventions to represents the currency valuesvoidsetCurrencyFormat(String format, Character minusSymbol, Character groupingSymbol, Integer groupingSize, Character decimalSymbol, Integer decimalSize, String currency) Sets the DecimalFormat for the currencies and all the corresponding symbolsvoidsetDecimalFormat(String format) Sets the string used to define the DecimalFormat used by this instance of ConventionsvoidsetDecimalFormat(String format, Character minusSymbol, Character groupingSymbol, Integer groupingSize, Character decimalSymbol, Integer decimalSize, Character percentSymbol, String exponent) Sets the DecimalFormat and all the corresponding symbolsvoidSets the SimpleDateFormat string for String parsing and Date formattingvoidsetTimeHourSystem(String timeHourSystem) Set the hour system used to display the time.voidsetupCurrencyFormat(String symbols) Sets the symbols for the DecimalFormat used for currenciesvoidsetupDecimalFormat(String symbols) Sets the symbols for the DecimalFormat used by this instance of ConventionsConverts the string passed as parameter into aEuroobject, using the current correct DecimalFormat for currencies of the instanceConverts the string passed as parameter into a Date, using the current correct SimpleDateFormat of the instanceConverts the string passed as parameter into a BigDecimal number, using the current correct DecimalFormat of the instancestring2LocalDate(String dateString) Converts a string representation of a date to aLocalDateobject.string2LocalDateTime(String dateString) Converts a string representation of a date and time to aLocalDateTimeobject.string2LocalTime(String timeString) Converts a string representation of a time to aLocalTimeobject.string2OffsetDateTime(@NotNull String dateString) Converts a string representation of a date to aOffsetDateTimeobject.string2OffsetTime(String timeString) Converts a string representation of a time to aOffsetTimeobject.string2ZonedDateTime(@NotNull String dateString) Converts a string representation of a date to aZonedDateTimeobject.
-
Field Details
-
CODING
A thread-safe Conventions object, with the standardCODING_FORMAT -
CODING_FORMAT
Defines the standard coding format- See Also:
-
_sdfParse
-
_sdfFormat
-
_strSdfParse
-
_strSdfFormat
-
_fdw
-
timeHourSystem
-
_decimalFormat
-
_decimalFormatSymbols
-
_format
-
_minusSymbol
protected char _minusSymbol -
_groupingSeparator
protected char _groupingSeparator -
_groupingSize
protected int _groupingSize -
_decimalSeparator
protected char _decimalSeparator -
_decimalSize
protected int _decimalSize -
_percentSymbol
protected char _percentSymbol -
_exponentString
-
_currencyDecimalFormat
-
_currencyDecimalFormatSymbols
-
_currencyFormat
-
_currencyMinusSymbol
protected char _currencyMinusSymbol -
_currencyGroupingSeparator
protected char _currencyGroupingSeparator -
_currencyGroupingSize
protected int _currencyGroupingSize -
_currencyDecimalSeparator
protected char _currencyDecimalSeparator -
_currencyDecimalSize
protected int _currencyDecimalSize -
_currencyString
-
displayUnitsMap
-
teacherDuty
-
-
Constructor Details
-
Conventions
public Conventions()Empty constructor, creates a thread-safe object -
Conventions
Creates an instance of Conventions in which the variables will be initialized eventually using the dictionary provided by theTeacher, passed as parameter, or with the default values set by theLang- Parameters:
t- The Teacher used to retrieve the variable's values
-
Conventions
Copy Constructor- Parameters:
c- An instance of Conventions
-
-
Method Details
-
getSdfParse
Returns the string that represents the format used by this instance of Conventions for the parsing of Dates (read a string and obtain a Date).- Returns:
- A string that represents the SimpleDateFormat used for the parsing of the Dates
-
getSdfFormat
Returns the string that represents the format used by this instance of Conventions for the format of Dates (read a Date and obtain a String).- Returns:
- A string that represents the SimpleDateFormat used for the reading of the Dates
-
getFdw
Returns the string that represents which is the day considered as first day of the week- Returns:
- "s" for sunday, "m" for monday
-
getTimeHourSystem
Returns the string that represents which hour system will be used; 24h or 12h- Returns:
"24"for 24h time format, or"12"for 24h time format
-
getFormat
Returns the string that represents the DecimalFormat used by this instance of Conventions for the format of numbers- Returns:
- A string that represents the DecimalFormat
-
getMinusSymbol
public char getMinusSymbol()Returns the char that represents the minus symbol for the DecimalFormat of this instance of Conventions- Returns:
- A char that represents the minus symbol
-
getGroupingSeparator
public char getGroupingSeparator()Returns the char that represents the thousands separator for the DecimalFormat of this instance of Conventions- Returns:
- A char that represents the thousands separator
-
getGroupingSize
public int getGroupingSize()Returns the number of the thousands grouping size for the DecimalFormat of this instance of Conventions- Returns:
- The size of the thousands grouping
-
getDecimalSeparator
public char getDecimalSeparator()Returns the char that represents the decimal separator for the DecimalFormat of this instance of Conventions- Returns:
- A char that represents the decimal separator
-
getDecimalSize
public int getDecimalSize()Returns the number of decimal digits (precision) for the DecimalFormat of this instance of Conventions- Returns:
- The number of decimal digits allowed
-
getPercentSymbol
public char getPercentSymbol()Returns the char that represents the symbol used for the percentual numbers by the DecimalFormat of this instance of Conventions- Returns:
- The char that represents the symbol used to indicate the percentual numbers
-
getExponentString
Returns the string that represents the exponent symbol used by the DecimalFormat of this instance of Conventions- Returns:
- The string that represents the exponents
-
getCurrencyFormat
Returns the string that represents the DecimalFormat used by this instance of Conventions to represents the currencies values- Returns:
- A string that represents the DecimalFormat used for currencies
-
getCurrencyMinusSymbol
public char getCurrencyMinusSymbol()Returns the char that represents the minus symbol for the DecimalFormat used by this instance of Conventions to represents the currencies values- Returns:
- A char that represents the minus symbol for currencies
-
getCurrencyGroupingSeparator
public char getCurrencyGroupingSeparator()Returns the char that represents the thousands separator for the DecimalFormat used by this instance of Conventions to represents the currencies values- Returns:
- A char that represents the thousands separator for currencies
-
getCurrencyGroupingSize
public int getCurrencyGroupingSize()Returns the number of the thousands grouping size for the DecimalFormat used by this instance of Conventions to represents the currencies values- Returns:
- The size of the thousands grouping for currencies
-
getCurrencyDecimalSeparator
public char getCurrencyDecimalSeparator()Returns the char that represents the decimal separator for the DecimalFormat used by this instance of Conventions to represents the currencies values- Returns:
- A char that represents the decimal separator for currencies
-
getCurrencyDecimalSize
public int getCurrencyDecimalSize()Returns the number of decimal digits (precision) for the DecimalFormat used by this instance of Conventions to represents the currencies values- Returns:
- The number of decimal digits allowed for the currencies
-
getCurrencyString
Returns the string that represents the currency symbol for the DecimalFormat used by thi instance of Conventions to represents the currencies values- Returns:
- The currency symbol string
-
getDisplayUnit
Retrieves the correctMeasureWrapperassociated (by the user's language preferences) to the displayUnit passed as parameter.
For example, if in the user's language preferences it's set that the kilometers must be shown as miles ( with $MEASURE_km=mi,2), so if the display unit passed as parameter represent the kilometers it will be returned theMeasureWrapperobject that represent the miles unit of measurement and its output decimal precision.- Parameters:
displayUnit- TheMeasurefrom wich retrieve the right display unit of measurement set for the specific language.- Returns:
- Retrieves the correct
MeasureWrapperof measurement associated (by the language user's preferences) to the displayUnit passed as parameter.
-
setSdf
Sets the SimpleDateFormat string for String parsing and Date formatting- Parameters:
sdfParse- String used as format to parse a String into a Date. If this param is null, the variable _strSdfParse is not set.sdfFormat- String used as format to format a Date into a String. If this param is null, the variable _strSdfFormat is not set.
-
setTimeHourSystem
Set the hour system used to display the time.- Parameters:
timeHourSystem- Possible values are:"24"for 24h format"12"for 12h format
-
setDecimalFormat
Sets the string used to define the DecimalFormat used by this instance of Conventions- Parameters:
format- The string used to define the DecimaFormat
-
setDecimalFormat
public void setDecimalFormat(String format, Character minusSymbol, Character groupingSymbol, Integer groupingSize, Character decimalSymbol, Integer decimalSize, Character percentSymbol, String exponent) Sets the DecimalFormat and all the corresponding symbols- Parameters:
format- A string that represents the DecimalFormat; ifnullthe format will be not setminusSymbol- A Character that represents the minus symbol; ifnullthe symbol will be not setgroupingSymbol- A Character that represents the thousands separator; ifnullthe separator will be not setgroupingSize- The size of the thousands grouping; ifnullthe size will be not setdecimalSymbol- A Character that represents the decimal separator; ifnullthe separator will be not setdecimalSize- The number of decimal digits allowed; ifnullthe number will be not setpercentSymbol- The char that represents the symbol used to indicate the percentual numbers; ifnullthe symbol will be not setexponent- The string that represents the exponents; ifnullthe exponent will be not set
-
setCurrencyFormat
Sets the string used to define the DecimalFormat used by this instance of Conventions to represents the currency values- Parameters:
format- The string used to define the DecimaFormat for the currencies
-
setCurrencyFormat
public void setCurrencyFormat(String format, Character minusSymbol, Character groupingSymbol, Integer groupingSize, Character decimalSymbol, Integer decimalSize, String currency) Sets the DecimalFormat for the currencies and all the corresponding symbols- Parameters:
format- A string that represents the DecimalFormat for the currencies; ifnullthe format will be not setminusSymbol- A Character that represents the minus symbol for currencies; ifnullthe symbol will be not setgroupingSymbol- A Character that represents the thousands separator for currencies; ifnullthe separator will be not setgroupingSize- The size of the thousands grouping for currencies; ifnullthe size will be not setdecimalSymbol- A Character that represents the decimal separator for currencies; ifnullthe symbol will be not setdecimalSize- The number of decimal digits allowed for the currencies; ifnullthe number will be not setcurrency- The currency symbol string; ifnullthe symbol will be not set
-
setupDecimalFormat
Sets the symbols for the DecimalFormat used by this instance of Conventions- Parameters:
symbols- A string of symbols, written according to the following order:
- the first character shall be used as a symbol for identifying negative numbers
- the second character shall be used as a group separator for the whole part. If this character is followed by a number, then this number points out the size of the group (forcing the datum defined in the DecimalFormat). To avoid using a group separator, the 0 digit can be entered or the figure can be left out.
- a character that will be used as a group separator for the fraction part. If this character is followed by a whole number, then this number points out the minimum number of decimal figures (forcing the datum defined in the DecimalFormat). By omitting the figure, we intend to avoid forcing a minimum number of decimal figures.
- a character that will be used as a symbol for identifying percentage numbers
- a string to be used as an exponent. The string must be reported in single quotes.
-
setupCurrencyFormat
Sets the symbols for the DecimalFormat used for currencies- Parameters:
symbols- A string of symbols, written according to the following order:
- a character that will be used as a symbol for identifying negative numbers
- a character that will be used as a group separator for the whole part. If this character is followed by a whole number, then this number points out the size of the group (forcing the datum defined in the DecimalFormat). To avoid using a group separator, the 0 digit can be entered or the figure can be left out.
- a character that will be used as a group separator for the fraction part. If the character is followed by a whole number, then this number points out the number of decimal figures required in the number (forcing the datum defined in the DecimalFormat). By omitting the figure, we intend to avoid forcing the number of decimal figures.
- a string to be used as a currency symbol. The possible string must be reported in single quotes. The currency symbol will only be entered if the format requires it
-
string2Decimal
Converts the string passed as parameter into a BigDecimal number, using the current correct DecimalFormat of the instance- Parameters:
s- The string to convert- Returns:
- The BigDecimal that corresponds to the string
- Throws:
ParseException- If an error occurs during the parsing of the string, aParseExceptionwill be raised
-
decimal2String
Converts the BigDecimal passed as parameter into a string, using the current correct DecimalFormat of the instance- Parameters:
d- The number to convert- Returns:
- The string that corresponds to the number
-
string2Date
Converts the string passed as parameter into a Date, using the current correct SimpleDateFormat of the instance- Parameters:
s- The string to convert; it is possible to use "now" to obtain a new Date()- Returns:
- The Date that corresponds to the string
- Throws:
ParseException- If an error occurs during the parsing of the string, aParseExceptionwill be raised
-
string2LocalDateTime
Converts a string representation of a date and time to aLocalDateTimeobject.If the input string is "now", the method returns the current date and time. Otherwise, it attempts to parse the string using the ISO date-time format (yyyy-MM-ddTHH:mm:ss). If the parsing fails with a
DateTimeParseException, the method attempts to parse the string using an alternative date-time format without the 'T' separator.- Parameters:
dateString- the string representation of the date and time. This can be "now" to get the current date and time.- Returns:
- the corresponding
LocalDateTimeobject. - Throws:
DateTimeParseException- if the string cannot be parsed into a validLocalDateTime.
-
string2LocalDate
Converts a string representation of a date to aLocalDateobject.If the input string is "now", the method returns the current date. Otherwise, it attempts to parse the string using the ISO local date format (yyyy-MM-dd).
- Parameters:
dateString- the string representation of the date. This can be "now" to get the current date.- Returns:
- the corresponding
LocalDateobject. - Throws:
DateTimeParseException- if the string cannot be parsed into a validLocalDate.
-
string2LocalTime
Converts a string representation of a time to aLocalTimeobject.If the input string is "now", the method returns the current time. Otherwise, it attempts to parse the string using the ISO time format (HH:mm:ss).
- Parameters:
timeString- the string representation of the time. This can be "now" to get the current time.- Returns:
- the corresponding
LocalTimeobject. - Throws:
DateTimeParseException- if the string cannot be parsed into a validLocalTime.
-
date2String
Converts the Date passed as parameter into a string, using the current correct SimpleDateFormat of the instance- Parameters:
d- The Date to convert- Returns:
- The string that corresponds to the Date
-
string2Currency
Converts the string passed as parameter into aEuroobject, using the current correct DecimalFormat for currencies of the instance- Parameters:
s- The string to convert- Returns:
- The Euro that corresponds to the string
-
currency2String
Converts theEuroobject passed as parameter into a string, using the current correct DecimalFormat for currencies of the instance- Parameters:
e- The Euro object to convert- Returns:
- The string that corresponds to the Euro
-
string2ZonedDateTime
public ZonedDateTime string2ZonedDateTime(@NotNull @NotNull String dateString) throws DateTimeParseException Converts a string representation of a date to aZonedDateTimeobject.If the input string is
now, the method returns the current date. Otherwise, it attempts to parse the string using the ISO zoned date time format (yyyy-MM-ddTHH:mm:ssXXX).- Parameters:
dateString- the string representation of the date. This can benowto get the current date.- Returns:
- the corresponding
ZonedDateTimeobject. - Throws:
DateTimeParseException- if the string cannot be parsed into a validZonedDateTime.
-
string2OffsetDateTime
public OffsetDateTime string2OffsetDateTime(@NotNull @NotNull String dateString) throws DateTimeParseException Converts a string representation of a date to aOffsetDateTimeobject.If the input string is
now, the method returns the current date. Otherwise, it attempts to parse the string using the ISO zoned date time format (yyyy-MM-ddTHH:mm:ssXXX).- Parameters:
dateString- the string representation of the date. This can benowto get the current date.- Returns:
- the corresponding
OffsetDateTimeobject. - Throws:
DateTimeParseException- if the string cannot be parsed into a validOffsetDateTime.
-
string2OffsetTime
Converts a string representation of a time to aOffsetTimeobject.If the input string is "now", the method returns the current time. Otherwise, it attempts to parse the string using the ISO time format (HH:mm:ss).
- Parameters:
timeString- the string representation of the time. This can be "now" to get the current time.- Returns:
- the corresponding
OffsetTimeobject. - Throws:
DateTimeParseException- if the string cannot be parsed into a validOffsetTime.
-