Skip to content

Instantly share code, notes, and snippets.

@amscotti
Created April 24, 2013 11:14
Show Gist options
  • Save amscotti/5451406 to your computer and use it in GitHub Desktop.
Save amscotti/5451406 to your computer and use it in GitHub Desktop.
Throws FormatException, Input DateTime is 2013-04-24 07:12:25.516, which formats to 201304240712 FormatException: Trying to read MM from 201304240712 at position 12
import 'package:intl/intl.dart';
void main() {
var dateFormat = new DateFormat("yyyyMMddHHmm");
DateTime now = new DateTime.now();
String strDate = dateFormat.format(now);
print("Input DateTime is ${now}, which formats to ${strDate}");
try {
var output = dateFormat.parse(strDate);
print("Output DateTime is ${output}, from the String ${strDate}");
} catch (e) {
print(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment