Here you can find the source of dayForAMorPM(String date)
public static int dayForAMorPM(String date)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static int dayForAMorPM(String date) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); Date dateparam = null;/*w w w. j av a2 s . c o m*/ try { dateparam = format.parse(date); } catch (ParseException e) { e.printStackTrace(); } Calendar calendar = Calendar.getInstance(); calendar.setTime(dateparam); return calendar.get(Calendar.AM_PM); } public static int dayForAMorPM(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return calendar.get(Calendar.AM_PM); } }