我怎样才能只从 textClock 获取小时

how can i get the Hour only from textClock

in this i am trying to get only hour from the textclock and show on my widget and it works perfectly on Android device and when test on BlackBerry it shows complete time like 12:50 PM instead of hour

              <TextClock
                android:id="@+id/tvHourWidget"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:fontFamily="sans-serif-black"
                android:format12Hour="hh"
                android:text="00"
                android:textColor="@color/colorPrimary"
                android:textSize="@dimen/basic_twice" />

here is the code i have tried

您无法设置设备是 12 小时制还是 24 小时制,您也无法在 TextView 中进行设置。因此,您必须同时使用 format12Hourformat24Hour 属性以确保在这两种情况下,格式均为 hh:

<TextClock
            android:id="@+id/tvHourWidget"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:fontFamily="sans-serif-black"
            android:format12Hour="hh"
            android:format24Hour="hh"
            android:text="00"
            android:textColor="@color/colorPrimary"
            android:textSize="@dimen/basic_twice" />

您可以改用文本视图、计时器和简单的日期格式器,并设置所需的 DATETIME 格式

Timer tmm=new Timer();
public void start(TextView tv1){


    tmm.schedule(new TimerTask() {
        @Override
        public void run() {
            tv1.setText(""+ my_time("HH"));
        }
    },1000,1000);

}
public void Stop()
{
    tmm.cancel();
}


        public static String my_time(String format)
        {
            try{
                return new SimpleDateFormat(format).format(Calendar.getInstance().getTime());


            }catch (Exception ex){}
            return null;
        }