Here is the simplest way:
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a", Locale.US);
String time = df.format(new Date());
and If you are looking for patterns, check this
https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html