/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/fundamentals/runtime-libraries/snippets/System.Globalization/DateTimeFormatInfo/csharp/serialize2.cs
31 строка
1 KB
Genevieve Warren
Extract remarks for System.Globalization* (#38912)
29 дек 2023, 20:03
Не верифицирован
29 дек 2023, 20:03
7f945f9
Код
Авторство
О чём код?
// <Snippet18> using System; using System.Globalization; using System.IO; public class SerializeEx2 { public static void Main() { // Open the file and retrieve the date string. StreamReader sr = new StreamReader(@".\DateData.dat"); String dateValue = sr.ReadToEnd(); // Parse the date. DateTime parsedDate = DateTime.ParseExact(dateValue, "o", DateTimeFormatInfo.InvariantInfo); // Convert it to local time. DateTime restoredDate = parsedDate.ToLocalTime(); // Display information on the date and time. Console.WriteLine("Deserialized date: {0:F}", restoredDate); Console.WriteLine("Current Culture: {0}", CultureInfo.CurrentCulture.Name); Console.WriteLine("Time Zone: {0}", TimeZoneInfo.Local.DisplayName); } } // The example displays the following output: // Deserialized date: lundi 18 août 2014 17:16:35 // Current Culture: fr-FR // Time Zone: (UTC+01:00) Brussels, Copenhagen, Madrid, Paris // </Snippet18>