Format the given Time value into the provided output,
using the specified layout. The layout can be a generic
variant or a custom one, where generics are indicated
via a single character:
"t" = 7:04
"T" = 7:04:02 PM
"d" = 3/30/2009
"D" = Monday, March 30, 2009
"f" = Monday, March 30, 2009 7:04 PM
"F" = Monday, March 30, 2009 7:04:02 PM
"g" = 3/30/2009 7:04 PM
"G" = 3/30/2009 7:04:02 PM
"y"
"Y" = March, 2009
"r"
"R" = Mon, 30 Mar 2009 19:04:02 GMT
"s" = 2009-03-30T19:04:02
"u" = 2009-03-30 19:04:02Z
For the US locale, these generic layouts are expanded in the
following manner:
"t" = "h:mm"
"T" = "h:mm:ss tt"
"d" = "M/d/yyyy"
"D" = "dddd, MMMM d, yyyy"
"f" = "dddd, MMMM d, yyyy h:mm tt"
"F" = "dddd, MMMM d, yyyy h:mm:ss tt"
"g" = "M/d/yyyy h:mm tt"
"G" = "M/d/yyyy h:mm:ss tt"
"y"
"Y" = "MMMM, yyyy"
"r"
"R" = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'"
"s" = "yyyy'-'MM'-'dd'T'HH':'mm':'ss"
"u" = "yyyy'-'MM'-'dd' 'HH':'mm':'ss'Z'"
Custom layouts are constructed using a combination of the
character codes indicated on the right, above. For example,
a layout of "dddd, dd MMM yyyy HH':'mm':'ss zzzz" will emit
something like this:
1
|
Monday, 30 Mar 2009 19:04:02 -08:00
|
Using these format indicators with Layout (Stdout etc) is
straightforward. Formatting integers, for example, is done
like so:
1
2
3
|
Stdout.formatln ("{:u}", 5);
Stdout.formatln ("{:b}", 5);
Stdout.formatln ("{:x}", 5);
|
Formatting date/time values is similar, where the format
indicators are provided after the colon:
1
2
3
|
Stdout.formatln ("{:t}", Clock.now);
Stdout.formatln ("{:D}", Clock.now);
Stdout.formatln ("{:dddd, dd MMMM yyyy HH:mm}", Clock.now);
|