Function

Description

convertUnits

Converts a number from one unit to another.

format

Formats a value as a string.

fromJson

Converts a JSON formatted string to a Bisikit

prettyPrintJson

Takes JSON thats difficult to read and makes it easier to read.

toDate

Converts the input value to a value of type Date.

toDateTime

Converts the input into a DateTime.

toDouble

Converts the input to a Double.

toInt

Converts the input to an Integer.

toJson

Converts a biskit to JSON

toLong

Converts the input to a Long.

toPDF

Converts a string containing XSL FO to a PDF attachment and also to a temporary file.

toPDF_from_docx

Converts a Word document to a PDF document.

toPDF_from_odt

Converts an Open Office document to a PDF document.

toString

Converts the input into a String.

 

convertUnits

convertUnit

 

The user provides the number to be converted to a different unit, the current unit and the unit to be converted. The source and target units must be of the same type (eg both weights or both lengths etc). The output is the converted value.

format

format

 

The user the property to be formatted and the pattern to be used for the output. Returned is the formatted string.

 

The format used is of this general syntax for numeric types (int, long and double):

 

 %[flags][width][.precision]conversion

 

The optional flags is a set of characters that modify the output format. The set of valid flags depends on conversion.

 

The optional width is a non-negative decimal integer indicating the minimum number of characters to be written to the output.

 

The optional precision is a non-negative decimal integer usually used to restrict the number of characters. The specific behavior depends on conversion.

 

The required conversion is a character indicating how the value should be formatted. The set of valid conversions depends on the value's data type.

 

The format used for date/time formatting is of this general syntax:

 

 %[flags][width]conversion

 

The optional flags and width are defined as above.

 

The required conversion is a two character sequence. The first character is 't' or 'T'. The second character indicates the format to be used.

 

Conversions

 

Conversions are divided into the following categories:

General - may be applied to any value type

Numeric

oInteger and Long

oDouble

Date/Time - may be applied to types which are capable of encoding a date or time: Long, Date and Datetime.

Percent - produces a literal '%'

Line Separator - produces the platform-specific line separator

The following table summarizes the supported conversions. Conversions denoted by an upper-case character (i.e. 'B', 'H', 'S', 'C', 'X', 'E', 'G', 'A', and 'T') are the same as those for the corresponding lower-case conversion characters except that the result is converted to upper case according to the rules of the prevailing locale.

 

Conversion

Value Category

Description

'b', 'B'

general

If the value is null, then the result is "false". Otherwise, the result is "true".

'h', 'H'

general

If the value is null, then the result is "null". Otherwise, the result is obtained by converting the value's hash code to hexadecimal.For integer and long values, this means the original value is converted to hexadecimal.

's', 'S'

general

If the value is null, then the result is "null". Otherwise, the result is obtained by a simple conversion to a string.

'd'

Int, Long

The result is formatted as a decimal integer

'o'

Int, Long

The result is formatted as an octal integer

'x', 'X'

Int, Long

The result is formatted as a hexadecimal integer

'e', 'E'

Double

The result is formatted as a decimal number in computerized scientific notation

'f'

Double

The result is formatted as a decimal number

'g', 'G'

Double

The result is formatted using computerized scientific notation or decimal format, depending on the precision and the value after rounding.

'a', 'A'

Double

The result is formatted as a hexadecimal floating-point number with a significand and an exponent

't', 'T'

date/time

Prefix for date and time conversion characters. See Date/Time Conversions.

'%'

percent

The result is a literal '%'

'n'

line separator

The result is the platform-specific line separator

 

Any characters not explicitly defined as conversions are illegal and are reserved for future extensions.

 

Date/Time Conversions

 

The following two tables show the conversion suffix characters for date and time values using the 't' and 'T' conversions. First, conversion characters used for formatting times:

 

'H'

Hour of the day for the 24-hour clock, formatted as two digits with a leading zero as necessary i.e. 00 - 23.

'I'

Hour for the 12-hour clock, formatted as two digits with a leading zero as necessary, i.e. 01 - 12.

'k'

Hour of the day for the 24-hour clock, i.e. 0 - 23.

'l'

Hour for the 12-hour clock, i.e. 1 - 12.

'M'

Minute within the hour formatted as two digits with a leading zero as necessary, i.e. 00 - 59.

'S'

Seconds within the minute, formatted as two digits with a leading zero as necessary, i.e. 00 - 60 ("60" is a special value required to support leap seconds).

'L'

Millisecond within the second formatted as three digits with leading zeros as necessary, i.e. 000 - 999.

'N'

Nanosecond within the second, formatted as nine digits with leading zeros as necessary, i.e. 000000000 - 999999999.

'p'

Locale-specific morning or afternoon marker in lower case, e.g."am" or "pm". Use of the conversion prefix 'T' forces this output to upper case.

'z'

RFC 822 style numeric time zone offset from GMT, e.g. -0800. This value will be adjusted as necessary for Daylight Saving Time. For Long, Date and Date-time, the time zone used is the default time zone for the server.

'Z'

A string representing the abbreviation for the time zone. This value will be adjusted as necessary for Daylight Saving Time. For Long, Date and Date-time, the time zone used is the default time zone for the server.

's'

Seconds since the beginning of the epoch starting at 1 January 1970 00:00:00 UTC.

'Q'

Milliseconds since the beginning of the epoch starting at 1 January 1970 00:00:00 UTC.

 

and these are the conversion characters used for formatting dates:

 

'B'

Locale-specific full month name, e.g. "January", "February".

'b'

Locale-specific abbreviated month name, e.g. "Jan", "Feb".

'h'

Same as 'b'.

'A'

Locale-specific full name of the day of the week, e.g. "Sunday", "Monday"

'a'

Locale-specific short name of the day of the week, e.g. "Sun", "Mon"

'C'

Four-digit year divided by 100, formatted as two digits with leading zero as necessary, i.e. 00 - 99

'Y'

Year, formatted as at least four digits with leading zeros as necessary, e.g. 0092 equals 92 CE for the Gregorian calendar.

'y'

Last two digits of the year, formatted with leading zeros as necessary, i.e. 00 - 99.

'j'

Day of year, formatted as three digits with leading zeros as necessary, e.g. 001 - 366 for the Gregorian calendar.

'm'

Month, formatted as two digits with leading zeros as necessary, i.e. 01 - 13.

'd'

Day of month, formatted as two digits with leading zeros as necessary, i.e. 01 - 31

'e'

Day of month, formatted as two digits, i.e. 1 - 31.

 

The following conversion characters are used for formatting common date/time compositions.

 

'R'

Time formatted for the 24-hour clock as "%tH:%tM"

'T'

Time formatted for the 24-hour clock as "%tH:%tM:%tS".

'r'

Time formatted for the 12-hour clock as "%tI:%tM:%tS %Tp". The location of the morning or afternoon marker ('%Tp') may be locale-dependent.

'D'

Date formatted as "%tm/%td/%ty".

'F'

ISO 8601 complete date formatted as "%tY-%tm-%td".

'c'

Date and time formatted as "%ta %tb %td %tT %tZ %tY", e.g. "Sun Jul 20 16:17:00 EDT 1969".

 

Any characters not explicitly defined as date/time conversion suffixes are illegal and are reserved for future extensions.

 

Flags

 

The following table summarizes the supported flags. y means the flag is supported for the indicated value types.

 

Flag

General

Int/Long

Double

Date/Time

Description

'-'

y

y

y

y

The result will be left-justified.

'#'

y

y2

y


The result should use a conversion-dependent alternate form

'+'


y3

y


The result will always include a sign

' '


y3

y


The result will include a leading space for positive values

'0'


y

y


The result will be zero-padded

','


y1

y4


The result will include locale-specific grouping separators

'('


y3

y4


The result will enclose negative numbers in parentheses

 

1.For 'd' conversion only.

2.For 'o', 'x', and 'X' conversions only.

3.For 'd' applied to Integer and Long.

4.For 'e', 'E', 'f', 'g', and 'G' conversions only.

Any characters not explicitly defined as flags are illegal and are reserved for future extensions.

 

Width

 

The width is the minimum number of characters to be written to the output. For the line separator conversion, width is not applicable; if it is provided, an exception will be thrown.

 

Precision

 

For general value types, precision is the maximum number of characters to be written to the output.

 

For integer, long, and date/time value types and the percent and line separator conversions, precision is not applicable; if precision is provided, an exception will be thrown. %[flags][width]conversion

fromJson

fromJson

 

The user provides the JSON to be converted. Optionally the user could also provide the name of the type of Biskit to be created, if this is used the conversion will use knowledge of the target type being created instead of just a generic conversion. The output is a Biskit version of the JSON string.

prettyPrintJson

prettyPrintJson

 

The user provides the ugly JSON to be prettified. The output is a prettier JSON string.

toDate

toDate

 

The user provides the data to be converted which could be either a DateTime or a Long (number of seconds that have elapsed since January 1, 1970). The output is a Date.

toDateTime

toDateTime

 

The user provides the data to be converted which could be either a Date or a Long (number of seconds that have elapsed since January 1, 1970). The output is a DateTime.

toDouble

toDouble

 

The user provides the data to be converted which could be either an Int, a Long or a String. The output is a Double.

toInt

toInt

 

The user provides the data to be converted which could be either a String, a Long or a Double. The output is a Integer.

toJson

toJson

 

The user provides the biskit to be converted. Optionally the user defines whether the JSON doesn't include properties of value null. The output is the JSON string.

toLong

toInt

 

The user provides the data to be converted which could be either a String, an Int or a Double. The output is a Long.

toPDF

Click to expand

 

The user provides a String holding the XSL FO data and optionally, the filename for the attachment, a title for the PDF file, the authors name, the creator, keywords (all to be stored in the metadadta) and resolution of the PDF file. The output is the PDF file as an attachment and a temporary file.

Some XSL FO tutorials:

http://www.herongyang.com/XSL-FO/

http://w3schools.sinsixx.com/xslfo/default.asp.htm

https://www.webucator.com/tutorial/learn-xsl-fo/index.cfm

https://www.antennahouse.com/comprehensive-xsl-fo-tutorials-and-samples-collection/

https://www.qctutorials.com/learning/xslfo/index.html

https://www.ibm.com/developerworks/library/x-xslfo2app/?ca=dnt-46h

http://www.cafeconleche.org/books/bible3/chapters/ch16.html

http://www.renderx.com/tutorial.html

The standard is described here:

https://www.w3.org/TR/xsl/

Barcodes

For PDFs to include barcodes, see the XSL FO workflow example mentioned above for a "Hello World" type example. For examples of all the types of barcode available, see http://barcode4j.sourceforge.net/examples.html

The format of the XML required inside the XSL FO file is described at http://barcode4j.sourceforge.net/2.1/barcode-xml.html

For details on the different types of barcode available, see https://github.com/lindell/JsBarcode/wiki

Note that the PDF barcodes (generated by Barcode4j) have a different set of barcode types from those available in the browser (generated by JsBarcode). In particular, the PDF barcodes can include 2D barcodes in QR format whereas those in the browser cannot.

toPDF_from_docx

docxToPDF

 

The user provides Docx file as a template and the Biskit to provide the information for the template. Output is the PDF file as an Attachment. When creating the Template in Word use <alt>i followed by f to bring up the Field option. The Field name required is MERGEFIELD, once selected fill the property name into the Field name box starting with a b. or biskit and encased in ${ }. If you copy and paste a merge field you must remember to right click and Edit Field in order to change the Field name.

toPDF_from_odt

pdffromodt

 

The user provides odt file as a template and the Biskit to provide the information for the template. Output is the PDF file as an Attachment.When creating the Template in ODT, use Insert->Field->More Fields (Ctrl+F2), choose Input Field, Insert and then type in the field required starting with a ${b. or ${biskit. and ending with a }

toString

Click to expand

 

The user provides the data to be converted which could be one of a large number of options, please see the image for the complete list. The output is a String.