I used
SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy, HH:mm");
String time = formatter.format(new Date());
to get t
I recommend you use java.time, the modern Java date and time API, for your date and time work.
ZoneId zone = ZoneId.systemDefault();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.uuuu, H:mm");
String dateTimeString = "12.03.2012, 17:31";
LocalDateTime dateTime = LocalDateTime.parse(dateTimeString, formatter);
long milliseconds = dateTime.atZone(zone).toInstant().toEpochMilli();
System.out.println(milliseconds);
When I run this in Europe/Zurich time zone, the output is:
1331569860000
java.time works nicely on both older and newer Android devices. It just requires at least Java 6.
org.threeten.bp with subpackages.java.time was first described.java.time to Java 6 and 7 (ThreeTen for JSR-310).