How can I show pm only in my digital watch

I am making an application because there are two digital chats in my application, so the current time is shown, and the other shows the time ISHA PARYER TIME, and this digital clock will only be set to hh:mm:ss and it won’t work like a regular watch. It will show only time, but it will show time in am , and I want to show it only in pm Please help me.

Here is the code:

  mCalendar.set(0, 0, 0, hr, min, second); 

and when I completed it

  mCalendar.set(mCalendar.AM_PM, mCalendar.PM); 

he realized an hour to about +3

+4
source share
2 answers

You may get an idea of ​​what you want to do. In this code, I show the time in 12 hour format, like AM and PM.

 private TimePickerDialog.OnTimeSetListener mTimeSetListener = new TimePickerDialog.OnTimeSetListener() { public void onTimeSet(TimePicker view, int hourOfDay, int minute) { TextView datehid = (TextView)findViewById(R.id.timehidden); if(hourOfDay>12) { datehid.setText(String.valueOf(hourOfDay-12)+ ":"+(String.valueOf(minute)+"pm")); } if(hourOfDay==12) { datehid.setText("12"+ ":"+(String.valueOf(minute)+"pm")); } if(hourOfDay<12) { datehid.setText(String.valueOf(hourOfDay)+ ":"+(String.valueOf(minute)+"am")); } } }; 

Hope this helps you.

+1
source

THANKS TO ALL OF YOU, BUT I GOT THIS :) AND HERE THIS

  mCalendar.set(0, 0, 0, hr, min, second); if (mCalendar.get(mCalendar.AM_PM) == Calendar.AM) { mCalendar.set(mCalendar.AM_PM, mCalendar.PM); } 
0
source

Source: https://habr.com/ru/post/1485937/


All Articles