當前位置: 首頁>>代碼示例>>Java>>正文


Java DateFormat.is24HourFormat方法代碼示例

本文整理匯總了Java中android.text.format.DateFormat.is24HourFormat方法的典型用法代碼示例。如果您正苦於以下問題:Java DateFormat.is24HourFormat方法的具體用法?Java DateFormat.is24HourFormat怎麽用?Java DateFormat.is24HourFormat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.text.format.DateFormat的用法示例。


在下文中一共展示了DateFormat.is24HourFormat方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createDialog

import android.text.format.DateFormat; //導入方法依賴的package包/類
static Dialog createDialog(
    Bundle args, Context activityContext, @Nullable OnTimeSetListener onTimeSetListener
) {
  final Calendar now = Calendar.getInstance();
  int hour = now.get(Calendar.HOUR_OF_DAY);
  int minute = now.get(Calendar.MINUTE);
  boolean is24hour = DateFormat.is24HourFormat(activityContext);

  if (args != null) {
    hour = args.getInt(TimePickerDialogModule.ARG_HOUR, now.get(Calendar.HOUR_OF_DAY));
    minute = args.getInt(TimePickerDialogModule.ARG_MINUTE, now.get(Calendar.MINUTE));
    is24hour = args.getBoolean(
        TimePickerDialogModule.ARG_IS24HOUR,
        DateFormat.is24HourFormat(activityContext));
  }

  return new DismissableTimePickerDialog(
      activityContext,
      onTimeSetListener,
      hour,
      minute,
      is24hour);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:24,代碼來源:TimePickerDialogFragment.java

示例2: onDeviceConfigurationChange

import android.text.format.DateFormat; //導入方法依賴的package包/類
public void onDeviceConfigurationChange(Configuration newConfig) {
    if (changingConfiguration) {
        return;
    }
    is24HourFormat = DateFormat.is24HourFormat(ApplicationLoader.applicationContext);
    systemDefaultLocale = newConfig.locale;
    if (languageOverride != null) {
        LocaleInfo toSet = currentLocaleInfo;
        currentLocaleInfo = null;
        applyLanguage(toSet, false);
    } else {
        Locale newLocale = newConfig.locale;
        if (newLocale != null) {
            String d1 = newLocale.getDisplayName();
            String d2 = currentLocale.getDisplayName();
            if (d1 != null && d2 != null && !d1.equals(d2)) {
                recreateFormatters();
            }
            currentLocale = newLocale;
            currentPluralRules = allRules.get(currentLocale.getLanguage());
            if (currentPluralRules == null) {
                currentPluralRules = allRules.get("en");
            }
        }
    }
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:27,代碼來源:LocaleController.java

示例3: getChangeSummary

import android.text.format.DateFormat; //導入方法依賴的package包/類
/**
 * Produce a summary of the Zen mode change to be read aloud as TTS.
 */
private CharSequence getChangeSummary(int mode, int minutes) {
    int indefinite = -1;
    int byMinute = -1;
    int byHour = -1;
    int byTime = -1;

    switch (mode) {
        case Global.ZEN_MODE_ALARMS:
            indefinite = R.string.zen_mode_summary_alarms_only_indefinite;
            byMinute = R.plurals.zen_mode_summary_alarms_only_by_minute;
            byHour = R.plurals.zen_mode_summary_alarms_only_by_hour;
            byTime = R.string.zen_mode_summary_alarms_only_by_time;
            break;
        case Global.ZEN_MODE_OFF:
            indefinite = R.string.zen_mode_summary_always;
            break;
    };

    if (minutes < 0 || mode == Global.ZEN_MODE_OFF) {
        return getString(indefinite);
    }

    long time = System.currentTimeMillis() + minutes * MINUTES_MS;
    String skeleton = DateFormat.is24HourFormat(this, UserHandle.myUserId()) ? "Hm" : "hma";
    String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
    CharSequence formattedTime = DateFormat.format(pattern, time);
    Resources res = getResources();

    if (minutes < 60) {
        return res.getQuantityString(byMinute, minutes, minutes, formattedTime);
    } else if (minutes % 60 != 0) {
        return res.getString(byTime, formattedTime);
    } else {
        int hours = minutes / 60;
        return res.getQuantityString(byHour, hours, hours, formattedTime);
    }
}
 
開發者ID:ric96,項目名稱:lineagex86,代碼行數:41,代碼來源:ZenModeVoiceActivity.java

示例4: onCreateDialog

import android.text.format.DateFormat; //導入方法依賴的package包/類
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    //Get the default time from the arguments:
    int hour = getArguments().getInt("hour");
    int minute = getArguments().getInt("minute");
    //Return a TimePickerDialog which has a default time of what was set in the constructor:
    return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
}
 
開發者ID:brianjaustin,項目名稱:permitlog-android,代碼行數:9,代碼來源:DriveTimeFragment.java

示例5: onCreateDialog

import android.text.format.DateFormat; //導入方法依賴的package包/類
@Override
public Dialog onCreateDialog(Bundle savedInstanceState){
    //Use the current time as the default values for the time picker
    final Calendar c = Calendar.getInstance();
    int hour = c.get(Calendar.HOUR_OF_DAY);
    int minute = c.get(Calendar.MINUTE);

    //Create and return a new instance of TimePickerDialog
    /*
        public constructor.....
        TimePickerDialog(Context context, int theme,
         TimePickerDialog.OnTimeSetListener callBack, int hourOfDay, int minute, boolean is24HourView)

        The 'theme' parameter allow us to specify the theme of TimePickerDialog

        .......List of Themes.......
        THEME_DEVICE_DEFAULT_DARK
        THEME_DEVICE_DEFAULT_LIGHT
        THEME_HOLO_DARK
        THEME_HOLO_LIGHT
        THEME_TRADITIONAL

     */
    TimePickerDialog tpd = new TimePickerDialog(getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_DARK
            ,this, hour, minute, DateFormat.is24HourFormat(getActivity()));

    //You can set a simple text title for TimePickerDialog
    //tpd.setTitle("Title Of Time Picker Dialog");

    /*.........Set a custom title for picker........*/
    TextView tvTitle = new TextView(getActivity());
    tvTitle.setText("TimePickerDialog Title");
    tvTitle.setBackgroundColor(Color.parseColor("#EEE8AA"));
    tvTitle.setPadding(5, 3, 5, 3);
    tvTitle.setGravity(Gravity.CENTER_HORIZONTAL);
    tpd.setCustomTitle(tvTitle);
    /*.........End custom title section........*/

    return tpd;
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:41,代碼來源:TimePickerFragment.java

示例6: onBindDialogView

import android.text.format.DateFormat; //導入方法依賴的package包/類
@Override
protected void onBindDialogView(View view) {
    super.onBindDialogView(view);

    if (DateFormat.is24HourFormat(context)) {
        time_picker.setIs24HourView(true);
    }

    //retrieving hour and minute
    final Calendar c = Calendar.getInstance();
    int hour = c.get(Calendar.HOUR_OF_DAY);
    time_picker.setCurrentHour(hour);
    int minute = c.get(Calendar.MINUTE);
    time_picker.setCurrentMinute(minute);
}
 
開發者ID:Cesarsk,項目名稱:Say_it,代碼行數:16,代碼來源:TimePickerPreference.java

示例7: onCreateDialog

import android.text.format.DateFormat; //導入方法依賴的package包/類
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the current time as the default values for the picker
    final Calendar c = Calendar.getInstance();
    int hour = c.get(Calendar.HOUR_OF_DAY);
    int minute = c.get(Calendar.MINUTE);

    // Create a new instance of TimePickerDialog and return it
    return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
}
 
開發者ID:pawanchauhan05,項目名稱:AndroidUtility,代碼行數:11,代碼來源:AlertDialog.java

示例8: onCreateDialog

import android.text.format.DateFormat; //導入方法依賴的package包/類
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    /* Use the last time chosen as the time that is selected when the dialog pops up. This is
     * stored in the global variables hour_end and minute_end. If it is the first time
     * the dialog is being launched, it will default to the current time.
     */
    int hour = ((GraphTabbed)getActivity()).hour_end;
    int minute = ((GraphTabbed)getActivity()).minute_end;


    // Create a new instance of TimePickerDialog and return it
    return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
}
 
開發者ID:minigridems,項目名稱:SERC-ENERYGY-METERING-MOBILE-APP,代碼行數:15,代碼來源:GraphTabbed.java

示例9: TimePicker

import android.text.format.DateFormat; //導入方法依賴的package包/類
/**
 * Create a new TimePicker component.
 *
 * @param container the parent container.
 */
public TimePicker(ComponentContainer container) {
  super(container);
  form = container.$form();
  final Calendar c = Calendar.getInstance();
  hour = c.get(Calendar.HOUR_OF_DAY);
  minute = c.get(Calendar.MINUTE);
  time = new TimePickerDialog(this.container.$context(),
      timePickerListener, hour, minute, DateFormat.is24HourFormat(this.container.$context()));

  instant = Dates.TimeInstant(hour, minute);
  androidUIHandler = new Handler();

}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:19,代碼來源:TimePicker.java

示例10: setDate

import android.text.format.DateFormat; //導入方法依賴的package包/類
public void setDate(int year, int month, int day){
        Calendar calendar = Calendar.getInstance();
        int hour, minute;
//        int currentYear = calendar.get(Calendar.YEAR);
//        int currentMonth = calendar.get(Calendar.MONTH);
//        int currentDay = calendar.get(Calendar.DAY_OF_MONTH);

        Calendar reminderCalendar = Calendar.getInstance();
        reminderCalendar.set(year, month, day);
        
        if(reminderCalendar.before(calendar)){
            Toast.makeText(this, "My time-machine is a bit rusty", Toast.LENGTH_SHORT).show();
            return;
        }

        if(mUserReminderDate!=null){
            calendar.setTime(mUserReminderDate);
        }

        if(DateFormat.is24HourFormat(this)){
            hour = calendar.get(Calendar.HOUR_OF_DAY);
        }
        else{

            hour = calendar.get(Calendar.HOUR);
        }
        minute = calendar.get(Calendar.MINUTE);

        calendar.set(year, month, day, hour, minute);
        mUserReminderDate = calendar.getTime();
        setReminderTextView();
//        setDateAndTimeEditText();
        setDateEditText();
    }
 
開發者ID:kotlin-korea,項目名稱:Minimal-Todo,代碼行數:35,代碼來源:AddToDoActivity.java

示例11: onCreateDialog

import android.text.format.DateFormat; //導入方法依賴的package包/類
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Calendar calendar = Calendar.getInstance();
    int hour = calendar.get(Calendar.HOUR_OF_DAY);
    int minute = calendar.get(Calendar.MINUTE);

    return new TimePickerDialog(context, timeSetListener, hour, minute,
        DateFormat.is24HourFormat(context));
}
 
開發者ID:BakkerTom,項目名稱:happy-news,代碼行數:10,代碼來源:TimePickerFragment.java

示例12: onCreateDialog

import android.text.format.DateFormat; //導入方法依賴的package包/類
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the current time as the default values for the picker
    final Calendar c = Calendar.getInstance();
    int hour = c.get(Calendar.HOUR_OF_DAY);
    int minute = c.get(Calendar.MINUTE);

    // Create a new instance of TimePickerDialog and return it
    return new TimePickerDialog(getActivity(), this, hour, minute,
            DateFormat.is24HourFormat(getActivity()));
}
 
開發者ID:smashingboxes,項目名稱:android-analytics,代碼行數:12,代碼來源:MainFragment.java

示例13: onCreateDialog

import android.text.format.DateFormat; //導入方法依賴的package包/類
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Calendar c = Calendar.getInstance();
    int hour = c.get(Calendar.HOUR_OF_DAY);
    int minute = c.get(Calendar.MINUTE);

    return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
}
 
開發者ID:segasunset,項目名稱:WeatherAlarmClock,代碼行數:10,代碼來源:AddAlarmActivity.java

示例14: getDetailedDateFormatter

import android.text.format.DateFormat; //導入方法依賴的package包/類
public static SimpleDateFormat getDetailedDateFormatter(Context context, Locale locale) {
  String dateFormatPattern;

  if (DateFormat.is24HourFormat(context)) {
    dateFormatPattern = getLocalizedPattern("MMM d, yyyy HH:mm:ss zzz", locale);
  } else {
    dateFormatPattern = getLocalizedPattern("MMM d, yyyy hh:mm:ss a zzz", locale);
  }

  return new SimpleDateFormat(dateFormatPattern, locale);
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:12,代碼來源:DateUtils.java

示例15: getDateTimeInterpreter

import android.text.format.DateFormat; //導入方法依賴的package包/類
/**
 * Get the interpreter which provides the text to show in the header column and the header row.
 * @return The date, time interpreter.
 */
public DateTimeInterpreter getDateTimeInterpreter() {
    if (mDateTimeInterpreter == null) {
        mDateTimeInterpreter = new DateTimeInterpreter() {
            @Override
            public String interpretDate(Calendar date) {
                try {
                    SimpleDateFormat sdf = mDayNameLength == LENGTH_SHORT ? new SimpleDateFormat("EEEEE M/dd", Locale.getDefault()) : new SimpleDateFormat("EEE M/dd", Locale.getDefault());
                    return sdf.format(date.getTime()).toUpperCase();
                } catch (Exception e) {
                    e.printStackTrace();
                    return "";
                }
            }

            @Override
            public String interpretTime(int hour) {
                Calendar calendar = Calendar.getInstance();
                calendar.set(Calendar.HOUR_OF_DAY, hour);
                calendar.set(Calendar.MINUTE, 0);

                try {
                    SimpleDateFormat sdf = DateFormat.is24HourFormat(getContext()) ? new SimpleDateFormat("HH:mm", Locale.getDefault()) : new SimpleDateFormat("hh a", Locale.getDefault());
                    return sdf.format(calendar.getTime());
                } catch (Exception e) {
                    e.printStackTrace();
                    return "";
                }
            }
        };
    }
    return mDateTimeInterpreter;
}
 
開發者ID:sathishmscict,項目名稱:Android-Week-View,代碼行數:37,代碼來源:WeekView.java


注:本文中的android.text.format.DateFormat.is24HourFormat方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。