TicksToDateTimeConverter.cs 898 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows.Data;
  8. namespace Aitex.Sorter.UI.Converter
  9. {
  10. public class TicksToDateTimeConverter : IValueConverter
  11. {
  12. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  13. {
  14. try
  15. {
  16. if (value == null) return "0";
  17. var dateTime =new DateTime(long.Parse(value.ToString()));
  18. return dateTime.ToString("yyyy-MM-dd HH:mm:ss");
  19. }
  20. catch (Exception)
  21. {
  22. return "0";
  23. }
  24. }
  25. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  26. {
  27. throw new NotImplementedException();
  28. }
  29. }
  30. }