当前位置: 首页>>代码示例>>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;未经允许,请勿转载。