The server where I am working in some routes it returns a Date with one extra number and it was causing a weird behavior in our application. Then I isolated the weird behavior to the following code:
import 'package:intl/intl.dart';
void main() {
final format = DateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ");
print(format.parse('2020-08-05T14:23:55.974582+00:00'));
print(format.parse('2020-08-05T14:23:55.9745829+00:00'));
}
produces the output:
2020-08-05 14:40:09.582
2020-08-05 17:06:20.829
Why the extra number 9
introduces 3 hours difference? I can not understand why.
I created a repl so you can try: https://repl.it/join/jfhehoqt-leonardosilva25
when I try to parse the same string in swift, it gives a different result than dart, both strings gives me the same date https://repl.it/join/ncjffdth-leonardosilva25
original swift code from repl for reference:
import Foundation
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSSZ"
print(dateFormatter.date(from: "2020-08-05T14:23:55.974582+00:00")!)
print(dateFormatter.date(from: "2020-08-05T14:23:55.9745829+00:00")!)