java get date marker field(am/pm)
java
Solution
You could use a `Calendar`.
Calendar cal = Calendar.getInstance();
cal.setTime(st);
if (cal.get(Calendar.AM_PM) == Calendar.PM) {
...
}
Make sure you don't have a time zone mismatch when you do this.
Problem
I need to get the field AM/PM in date object. How can i get it? This is my code. ``` String startTime ="01:05 PM"; SimpleDateFormat sdf = new SimpleDateFormat("hh:mm aa"); Date st = sdf.parse(startTime); ```