I want to convert UTC time zone to local time zone.
I use this code to convert from long object to UTC date time.
public class LongToDateTimeConverter : IValueConverter
{
DateTime _time = new DateTime(1970, 1, 1, 0, 0, 0, 0);
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
long dateTime = (long)value;
return $"{_time.AddSeconds(dateTime).ToString("HH:mm:ss tt")} UTC";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
After I display the utc time zone with this code:
<Label Text="{Binding WeatherDataCurrent.Sys.Sunrise, Converter={StaticResource longToDateTimeConverter}}"
HorizontalTextAlignment="Center"
Grid.Row="1"
Grid.Column="0"
TextColor="White"
FontAttributes="Bold"/>
How to convert this UTC time to local time ?