I have a ZonedDateTime, and I want to display it so that the datetime is formatted with a short date and a short time configured on the workstation, followed by an offset (something like ... 05/01/2005 14:30 PM - 5:00). I was expecting something like this to work ...
var patternDateTimeOffset = ZonedDateTimePattern.CreateWithCurrentCulture("g o<m>", DateTimeZoneProviders.Tzdb); lblOriginalDateTimeAndOffsetVal.Text = patternDateTimeOffset.Format(zonedDateTime);
BUT, it seems that āgā is not supported in ZonedDateTimePattern as it is in LocalDateTimePattern. In the above code, a NodaTime.Text.InvalidPatternException is thrown.
I could replace "g" with "MM / dd / yyyy hh: mm", but then he did not use the current culture.
I could use LocalDateTimePattern for datetime and then combine the offset using ZonedDateTimePattern. It works, but it seems ugly.
This seems pretty common. I am new to NodaTime, so I'm sure something is missing. I am using NodaTime 1.3.1 and targeting .net 4.0. Any help is appreciated.
source share