Numbers and dates
Format numbers and dates, such as a currency or a short date
Introduction
StellarAdmin displays numeric properties using NumberDisplay, and DateOnly, DateTime, DateTimeOffset or TimeOnly properties with DateDisplay.
NumberDisplay uses a fixed width for every digit, so numbers in a column line up. In the grid, numbers are aligned to the right.
Formatting a number or a date
By default, no formatting is applied to number displays. Date displays follow the culture: dates use its long date without the weekday and with short month names, such as Oct 14, 2026 in en-US and 14. Okt. 2026 in de-DE, times use its short time, such as 9:30 AM, and dates with a time join the two with a space, such as Oct 14, 2026 9:30 AM.
To format a number or a date, set Format to a .NET format string, such as "C" or "N2" for a number, or "d MMM yyyy" for a date. The example below displays the booking's total as a currency, and its departure date with the day of the week:
using StellarAdmin.Resources.Displays;
columns.Add(booking => booking.TotalAmount, column =>
column.UseDisplay<NumberDisplay>(number => number.Format = "C"));
columns.Add(booking => booking.Departure.StartDate, column =>
column.UseDisplay<DateDisplay>(date => date.Format = "ddd d MMM yyyy"));

You can also use the [DisplayFormat] on the property to apply formatting:
[DisplayFormat(DataFormatString = "{0:C}")]
public decimal Total { get; set; }[DataType(DataType.Date)] also sets a [DisplayFormat], which displays the culture's short date, such as 10/14/2026 in the en-US culture. To display the date as 14 Oct 2026 instead, set Format to "d MMM yyyy".
Choosing the culture
StellarAdmin formats values in the request's culture, so "C" displays the server's currency, unless your app sets a request culture with request localization.