Example usage for android.widget TextClock setFormat12Hour

List of usage examples for android.widget TextClock setFormat12Hour

Introduction

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

Prototype

@RemotableViewMethod
public void setFormat12Hour(CharSequence format) 

Source Link

Document

Specifies the formatting pattern used to display the date and/or time in 12-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//from   w  w w  .  j a  v  a 2  s.  c  o  m
 */
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
 */// ww  w .ja v a 2s.  com
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//from  www . j a  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());
    }
}