fork download
  1. import java.text.ParseException;
  2. import java.text.SimpleDateFormat;
  3. import java.util.Date;
  4. import java.util.Locale;
  5. import java.util.TimeZone;
  6.  
  7. public class Main {
  8. public static void main(String[] args) {
  9. SimpleDateFormat parser = new SimpleDateFormat("dd MMM yyyy HH:mm:ss", Locale.GERMAN);
  10. parser.setLenient(false);
  11. parser.setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
  12.  
  13. SimpleDateFormat formatter = new SimpleDateFormat("dd MMM yyyy hh:mm:ss a", Locale.GERMAN);
  14. formatter.setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
  15. try {
  16. Date date = parser.parse("08 März 2015 02:15:20");
  17. System.out.println(formatter.format(date));
  18. } catch (ParseException e) {
  19. e.printStackTrace();
  20. }
  21. }
  22. }
Success #stdin #stdout 0.16s 55020KB
stdin
Standard input is empty
stdout
08 März 2015 02:15:20 vorm.