List of usage examples for android.text.format DateFormat is24HourFormat
public static boolean is24HourFormat(Context context)
From source file:ca.mudar.parkcatcher.ui.fragments.TimePickerFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { ((ParkingApp) getActivity().getApplicationContext()).updateUiLanguage(); final GregorianCalendar c = mListener.getParkingCalendar(); 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())); }
From source file:roommateapp.info.droid.TimePickerFragment.java
/** * On create of the time picker dialog//from ww w. j a v a 2 s . com */ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Create a new instance of TimePickerDialog and return it picker = new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity())); int cMin = DateHelper.getCurrentMinute(); int cHour = DateHelper.getCurrentHour(); String curTime = DateHelper.getTimeString(cHour, cMin); String selTime = DateHelper.getTimeString(hour, minute); String closingTime = DateHelper.getClosingTime(this.buildingActivity.getBuilding()); int compareTimes = closingTime.compareTo(curTime); // Show a reset-button if the current time isnt the selected if (!curTime.equals(selTime) && compareTimes > 1) { picker.setButton(DialogInterface.BUTTON_NEUTRAL, this.c.getText(R.string.filter_reset), new DialogInterface.OnClickListener() { // Set the selected time to the current time public void onClick(DialogInterface dialog, int which) { int cMin = DateHelper.getCurrentMinute(); int cHour = DateHelper.getCurrentHour(); buildingActivity.setTimebar(cHour, cMin); picker.updateTime(cHour, cMin); } }); } return picker; }
From source file:com.dgsd.android.ShiftTracker.Adapter.DayAdapter.java
public DayAdapter(Context context, Cursor c, int julianDay) { super(context, c, false); inflater = LayoutInflater.from(context); mJulianDay = julianDay;/*from w w w . j av a 2s. c o m*/ mIs24Hour = DateFormat.is24HourFormat(context); mStringBuilder = new StringBuilder(); mFormatter = new Formatter((mStringBuilder)); mCurrencyFormatter = NumberFormat.getCurrencyInstance(); //Caching mIdToTimeArray = new SparseArray<String>(); mIdToPayArray = new SparseArray<String>(); mShowIncomePref = Prefs.getInstance(context).get(context.getString(R.string.settings_key_show_income), true); }
From source file:org.videolan.vlc.gui.dialogs.TimePickerDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { setStyle(STYLE_NO_FRAME, R.attr.advanced_options_style); action = getArguments().getInt("action"); boolean is24 = true; int hour = 0; int minute = 0; if (action == ACTION_SLEEP) { // Use the current time as the default values for the picker final Calendar c = VLCApplication.sPlayerSleepTime != null ? VLCApplication.sPlayerSleepTime : Calendar.getInstance(); hour = c.get(Calendar.HOUR_OF_DAY); minute = c.get(Calendar.MINUTE); is24 = DateFormat.is24HourFormat(getActivity()); }//from ww w. j av a 2 s .co m // Create a new instance of TimePickerDialog and return it return new TimePickerDialog(getActivity(), this, hour, minute, is24); }
From source file:edu.usf.cutr.opentripplanner.android.util.DateTimeDialog.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override//from w w w . j a v a2 s.c o m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.date_time_dialog, container); spinScheduleType = (Spinner) view.findViewById(R.id.spinScheduleType); pickerTime = (TimePicker) view.findViewById(R.id.timePicker1); pickerDate = (DatePicker) view.findViewById(R.id.datePicker1); btnOk = (Button) view.findViewById(R.id.btnOk); btnCancel = (Button) view.findViewById(R.id.btnCancel); getDialog().setTitle(getResources().getString(R.string.date_time_selector_title)); getDialog().setCanceledOnTouchOutside(true); pickerTime.setIs24HourView(DateFormat.is24HourFormat(getActivity())); //TimePicker state needs to be saved manually because of this bug in Android that affects at least ICS: http://code.google.com/p/android/issues/detail?id=22754 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { pickerTime.setSaveFromParentEnabled(false); } OnClickListener oclOk = new OnClickListener() { @Override public void onClick(View v) { Calendar cal = Calendar.getInstance(); cal.set(pickerDate.getYear(), pickerDate.getMonth(), pickerDate.getDayOfMonth(), pickerTime.getCurrentHour(), pickerTime.getCurrentMinute()); ArriveBySpinnerItem selectedSscheduleType = (ArriveBySpinnerItem) spinScheduleType .getSelectedItem(); ((MyActivity) getActivity()).onDateComplete(cal.getTime(), selectedSscheduleType.getValue()); dismiss(); } }; btnOk.setOnClickListener(oclOk); OnClickListener oclCancel = new OnClickListener() { @Override public void onClick(View v) { dismiss(); } }; btnCancel.setOnClickListener(oclCancel); ArrayAdapter<ArriveBySpinnerItem> arriveByTypeAdapter = new ArrayAdapter<ArriveBySpinnerItem>(getActivity(), android.R.layout.simple_spinner_dropdown_item, new ArriveBySpinnerItem[] { new ArriveBySpinnerItem( getResources().getString(R.string.date_time_selector_spinner_depart), false), new ArriveBySpinnerItem( getResources().getString(R.string.date_time_selector_spinner_arrive), true) }); spinScheduleType.setAdapter(arriveByTypeAdapter); return view; }
From source file:com.lambdasoup.quickfit.ui.TimeDialogFragment.java
@NonNull @Override//from ww w .j ava 2s . co m public Dialog onCreateDialog(Bundle savedInstanceState) { int hour = getArguments().getInt(KEY_OLD_HOUR); int minute = getArguments().getInt(KEY_OLD_MINUTE); // Create a new instance of TimePickerDialog and return it return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity())); }
From source file:com.dgsd.android.ShiftTracker.Adapter.WeekAdapter.java
public WeekAdapter(Context context, Cursor c, int julianDay) { super(context, c, false); inflater = LayoutInflater.from(context); mStartingJulianDay = julianDay;/*from w w w . j a v a 2 s. co m*/ mRand = new Random(); mTime = new Time(); mIs24Hour = DateFormat.is24HourFormat(context); mStringBuilder = new StringBuilder(); mFormatter = new Formatter((mStringBuilder)); mCurrencyFormatter = NumberFormat.getCurrencyInstance(); //Caching mJdToTitleArray = new SparseArray<String>(); mIdToTimeArray = new SparseArray<String>(); mIdToPayArray = new SparseArray<String>(); mCurrentJulianDay = TimeUtils.getCurrentJulianDay(); mShowIncomePref = Prefs.getInstance(context).get(context.getString(R.string.settings_key_show_income), true); }
From source file:net.xisberto.work_schedule.PeriodListAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.period_list_item, null); }//from w w w .j a v a 2 s . c o m final Period period = (Period) getItem(position); ((TextView) convertView.findViewById(R.id.period_label)).setText(context.getString(period.getLabelId())); ((TextView) convertView.findViewById(R.id.period_time)) .setText(period.formatTime(DateFormat.is24HourFormat(context))); CompoundButton check_alarm = (CompoundButton) convertView.findViewById(R.id.check_alarm); if (show_checkboxes) { check_alarm.setChecked(period.enabled); check_alarm.setOnClickListener(new OnClickListener() { @Override public void onClick(View check_box) { boolean isChecked = ((CompoundButton) check_box).isChecked(); period.enabled = isChecked && (period.time.getTimeInMillis() > System.currentTimeMillis()); period.setAlarm(context, true); period.persist(context); ((CompoundButton) check_box).setChecked(period.enabled); } }); } else { check_alarm.setVisibility(View.GONE); LinearLayout layout_labels = (LinearLayout) convertView.findViewById(R.id.layout_labels); LayoutParams params = (LayoutParams) layout_labels.getLayoutParams(); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); layout_labels.setLayoutParams(params); } return convertView; }
From source file:com.snowpuppet.alert.formclock.FormClockView.java
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // Attribute initialization final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FormClockView, defStyleAttr, defStyleRes);/*from w ww . j a v a 2 s .c om*/ // Configure renderers mHourMinOptions = new FormClockRenderer.Options(); mHourMinOptions.textSize = a.getDimension(R.styleable.FormClockView_textSize, TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 55, getResources().getDisplayMetrics())); mHourMinOptions.charSpacing = a.getDimension(R.styleable.FormClockView_charSpacing, TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 8, getResources().getDisplayMetrics())); mHourMinOptions.is24hour = DateFormat.is24HourFormat(context); mHourMinOptions.glyphAnimAverageDelay = 500; mHourMinOptions.glyphAnimDuration = 2000; mSecondsOptions = new FormClockRenderer.Options(mHourMinOptions); mSecondsOptions.onlySeconds = true; mSecondsOptions.textSize /= 2; mSecondsOptions.glyphAnimAverageDelay = 0; mSecondsOptions.glyphAnimDuration = 750; mColor1 = a.getColor(R.styleable.FormClockView_color1, getColorFromRes(context, R.color.colorAccent)); mColor2 = a.getColor(R.styleable.FormClockView_color2, getColorFromRes(context, R.color.colorPrimary)); mColor3 = a.getColor(R.styleable.FormClockView_color3, getColorFromRes(context, R.color.clockColor1)); a.recycle(); regenerateRenderers(); }
From source file:com.appsimobile.appsii.timezonepicker.TimeZoneData.java
public TimeZoneData(Context context, String defaultTimeZoneId, long timeMillis) { mContext = context;//from w w w. j a v a2 s . co m is24HourFormat = TimeZoneInfo.is24HourFormat = DateFormat.is24HourFormat(context); mDefaultTimeZoneId = mAlternateDefaultTimeZoneId = defaultTimeZoneId; long now = System.currentTimeMillis(); if (timeMillis == 0) { mTimeMillis = now; } else { mTimeMillis = timeMillis; } mPalestineDisplayName = context.getResources().getString(R.string.palestine_display_name); loadTzs(context); Log.i(TAG, "Time to load time zones (ms): " + (System.currentTimeMillis() - now)); // now = System.currentTimeMillis(); // printTz(); // Log.i(TAG, "Time to print time zones (ms): " + // (System.currentTimeMillis() - now)); }