Example usage for android.widget TextClock setFormat24Hour

List of usage examples for android.widget TextClock setFormat24Hour

Introduction

In this page you can find the example usage for android.widget TextClock setFormat24Hour.

Prototype

@RemotableViewMethod
public void setFormat24Hour(CharSequence format) 

Source Link

Document

Specifies the formatting pattern used to display the date and/or time in 24-hour mode.

Usage

From source file:com.stasbar.knowyourself.Utils.java

/***
 * Formats the time in the TextClock according to the Locale with a special
 * formatting treatment for the am/pm label.
 *
 * @param clock   - TextClock to format//  w w w  .  java2  s.com
 */
public static void setTimeFormat(TextClock clock) {
    if (clock != null) {
        // Get the best format for 12 hours mode according to the locale
        clock.setFormat12Hour(get12ModeFormat(0.4f /* amPmRatio */));
        // Get the best format for 24 hours mode according to the locale
        clock.setFormat24Hour(get24ModeFormat());
    }
}

From source file:com.androidinspain.deskclock.Utils.java

/***
 * Formats the time in the TextClock according to the Locale with a special
 * formatting treatment for the am/pm label.
 *
 * @param clock          TextClock to format
 * @param includeSeconds whether or not to include seconds in the clock's time
 *//*from  w  ww .j  a  v  a 2s .  c  o  m*/
public static void setTimeFormat(TextClock clock, boolean includeSeconds) {
    if (clock != null) {
        // Get the best format for 12 hours mode according to the locale
        clock.setFormat12Hour(get12ModeFormat(0.4f /* amPmRatio */, includeSeconds));
        // Get the best format for 24 hours mode according to the locale
        clock.setFormat24Hour(get24ModeFormat(includeSeconds));
    }
}

From source file:com.android.deskclock.Utils.java

/***
 * Formats the time in the TextClock according to the Locale with a special
 * formatting treatment for the am/pm label.
 * @param context - Context used to get user's locale and time preferences
 * @param clock - TextClock to format//  w  ww .  ja v a 2 s . com
 */
public static void setTimeFormat(Context context, TextClock clock) {
    if (clock != null) {
        // Get the best format for 12 hours mode according to the locale
        clock.setFormat12Hour(get12ModeFormat(context, true /* showAmPm */));
        // Get the best format for 24 hours mode according to the locale
        clock.setFormat24Hour(get24ModeFormat());
    }
}