Skip to content Skip to sidebar Skip to footer

How Can I Select A.m Or P.m Time In Timepicker?

I'm getting difference between two dates excluding weekend.But I want to get the time A.M at the end of the day.Because If staff start to work at the p.m then I want to add permiss

Solution 1:

use this

SimpleDateFormatdateFormat=newSimpleDateFormat("dd-MMM-yy hh.mm.ss.S aa");
 StringformattedDate= dateFormat.format(newDate()).toString();
 System.out.println(formattedDate);

you will get 11-Aug-05 12.25.15.375 PM

Solution 2:

If you want to get AM or PM from Calander object do below code

Calendar now = Calendar.getInstance();
int a = now.get(Calendar.AM_PM);
if(a == Calendar.AM)
     //the time is PM . do necessary actionselse// time is PM . Do neccessary actions

Post a Comment for "How Can I Select A.m Or P.m Time In Timepicker?"