I have been provided a time in this format "ddMMyyHHmmss". I know the time is in UTC format. I would like to use the NodaTime library to convert this to my local timezone but I can't seem to figure it out. My local timezone target is to be New Zealand.
Here's what I have tried:
var pattern = LocalDateTimePattern.CreateWithInvariantCulture("ddMMyyHHmmss");
var parseResult = pattern.Parse(utcDateTime);
if (!parseResult.Success)
{
throw new InvalidDataException("Invalid time specified " + date + time);
}
var timeZone = DateTimeZoneProviders.Bcl["New Zealand Standard Time"];
var zone = new ZonedDateTime(
localDateTime,
timeZone,
timeZone.GetUtcOffset(SystemClock.Instance.Now));
return new DateTime(zone.ToInstant().Ticks);