Date, Time, and Number Formats

Sample Manager Help

This topic covers formatting options for formatting the display of dates, times, and numbers within LabKey Sample Manager.

Set DateTime, Date, and Time Display Formats

An administrator can configure the way DateTime, Date, and Time field values are displayed in the application. This does not affect how values may be imported, but can be used to standardize or simplify the display to users, using the format strings outlined below.

There are three separate format strings available for Date-Times, Dates, and Times, as shown in the image below.

For example, the default display string for DateTime values is yyyy-MM-dd HH:mm. If your research is concerned only with dates and does not need to track or see the times as well, you can remove them from how these values are shown to users as follows:

  • Select > Application Settings.
  • Edit the Default display format for date-times to suit your needs. Shown here, the default without the time portion:
  • Click Save

This new format will be used to display all DateTime values in all projects in your application.

In this example, the "time" portion of the DateTime field is still present and can be shown later or in reporting. If you were to instead change the field type to "Date", the time portion of that value would be dropped.

Note that time zone values (z, Z, X) are not supported in Sample Manager or LabKey Biologics.

DateTime, Date, and Time Field Format Strings

Format strings used to describe dates, date-times, and times must be compatible with the format accepted by the Java class SimpleDateFormat. For more advanced options and examples, see the LabKey Server documentation. The following table has a partial guide to pattern symbols you may find useful in Sample Manager:

LetterDate/Time ComponentExamples
yYear'yyyy' = 1996; 'yy' = 96
MMonth in year'MMMM' = January; 'MMM' = Jan; 'MM' = 01
dDay in month'dd' = 10
aAm/pm markerPM
kHour in day (1-24)24
h .......Hour in am/pm (1-12) .......12 .......
mMinute in hour30
sSecond in minute33

Note that the LabKey date parser does not recognize time-only date strings. This means that you need to enter a full date string even when you wish to display time only. For example, you might enter a value of "2/2/09 4:00 PM" in order to display "04 PM" when using the format string "hh aa".

Number Format Strings

Format strings for Integer and Decimal fields must be compatible with the format that the java class DecimalFormat accepts. A valid DecimalFormat is a pattern specifying a prefix, numeric part, and suffix. For more information see the Java documentation. The following table has an abbreviated guide to pattern symbols:

SymbolLocationLocalized?Meaning
0NumberYesDigit
#NumberYesDigit, zero shows as absent
.NumberYesDecimal separator or monetary decimal separator
-NumberYesMinus sign
,NumberYesGrouping separator

Examples

The following examples apply to Date Type fields.

Format StringDisplay Result
yyyy-MM-dd HH:mm2008-05-17 01:45
yyyy-MM-dd HH:mm a2008-05-17 01:45 PM
yyyy-MM-dd HH:mm:ss.SSS2008-05-17 01:45:55.127
MMMM dd yyyyJanuary 17 2008

The following examples apply to Decimal fields.

Format StringDisplay Result
<no string>85.0
085
000085
.0085.00
000.000085.000
000,000085,000
-000,000-085,000

Java Reference Documents

Dates: https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/text/SimpleDateFormat.html

Numbers: https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/text/DecimalFormat.html

Related Topics

Was this content helpful?

Log in or register an account to provide feedback


previousnext
 
expand allcollapse all