android.text.format.DateFormat Java Examples

The following examples show how to use android.text.format.DateFormat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: ticdesign   Author: mobvoi   File: TimePickerSpinnerDelegate.java    License: Apache License 2.0 6 votes vote down vote up
private void getHourFormatData() {
    final String bestDateTimePattern = DateFormat.getBestDateTimePattern(mCurrentLocale,
            (mIs24HourView) ? "Hm" : "hm");
    final int lengthPattern = bestDateTimePattern.length();
    mHourWithTwoDigit = false;
    char hourFormat = '\0';
    // Check if the returned pattern is single or double 'H', 'h', 'K', 'k'. We also save
    // the hour format that we found.
    for (int i = 0; i < lengthPattern; i++) {
        final char c = bestDateTimePattern.charAt(i);
        if (c == 'H' || c == 'h' || c == 'K' || c == 'k') {
            mHourFormat = c;
            if (i + 1 < lengthPattern && c == bestDateTimePattern.charAt(i + 1)) {
                mHourWithTwoDigit = true;
            }
            break;
        }
    }
}
 
Example #2
Source Project: Conversations   Author: iNPUTmice   File: UIHelper.java    License: GNU General Public License v3.0 6 votes vote down vote up
private static String readableTimeDifference(Context context, long time,
                                             boolean fullDate) {
	if (time == 0) {
		return context.getString(R.string.just_now);
	}
	Date date = new Date(time);
	long difference = (System.currentTimeMillis() - time) / 1000;
	if (difference < 60) {
		return context.getString(R.string.just_now);
	} else if (difference < 60 * 2) {
		return context.getString(R.string.minute_ago);
	} else if (difference < 60 * 15) {
		return context.getString(R.string.minutes_ago, Math.round(difference / 60.0));
	} else if (today(date)) {
		java.text.DateFormat df = DateFormat.getTimeFormat(context);
		return df.format(date);
	} else {
		if (fullDate) {
			return DateUtils.formatDateTime(context, date.getTime(),
					FULL_DATE_FLAGS);
		} else {
			return DateUtils.formatDateTime(context, date.getTime(),
					SHORT_DATE_FLAGS);
		}
	}
}
 
Example #3
Source Project: android_9.0.0_r45   Author: lulululbj   File: TextClock.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Update the displayed time if this view and its ancestors and window is visible
 */
private void onTimeChanged() {
    // mShouldRunTicker always equals the last value passed into onVisibilityAggregated
    if (mShouldRunTicker) {
        mTime.setTimeInMillis(System.currentTimeMillis());
        setText(DateFormat.format(mFormat, mTime));
        setContentDescription(DateFormat.format(mDescFormat, mTime));
    }
}
 
Example #4
Source Project: trekarta   Author: andreynovikov   File: MapCoverageLayer.java    License: GNU General Public License v3.0 6 votes vote down vote up
public MapCoverageLayer(Context context, Map map, Index mapIndex, float scale) {
    super(map);
    mContext = context;
    mMapIndex = mapIndex;
    mPresentAreaStyle = AreaStyle.builder().fadeScale(FADE_ZOOM).blendColor(COLOR_ACTIVE).blendScale(10).color(Color.fade(COLOR_ACTIVE, AREA_ALPHA)).build();
    mOutdatedAreaStyle = AreaStyle.builder().fadeScale(FADE_ZOOM).blendColor(COLOR_OUTDATED).blendScale(10).color(Color.fade(COLOR_OUTDATED, AREA_ALPHA)).build();
    mMissingAreaStyle = AreaStyle.builder().fadeScale(FADE_ZOOM).blendColor(COLOR_MISSING).blendScale(10).color(Color.fade(COLOR_MISSING, AREA_ALPHA)).build();
    mDownloadingAreaStyle = AreaStyle.builder().fadeScale(FADE_ZOOM).blendColor(COLOR_DOWNLOADING).blendScale(10).color(Color.fade(COLOR_DOWNLOADING, AREA_ALPHA)).build();
    mSelectedAreaStyle = AreaStyle.builder().fadeScale(FADE_ZOOM).blendColor(COLOR_SELECTED).blendScale(10).color(Color.fade(COLOR_SELECTED, AREA_ALPHA)).build();
    mDeletedAreaStyle = AreaStyle.builder().fadeScale(FADE_ZOOM).blendColor(COLOR_DELETED).blendScale(10).color(Color.fade(COLOR_DELETED, AREA_ALPHA)).build();
    mLineStyle = LineStyle.builder().fadeScale(FADE_ZOOM + 1).color(Color.fade(Color.DKGRAY, 0.6f)).strokeWidth(0.5f * scale).fixed(true).build();
    mTextStyle = TextStyle.builder().fontSize(11 * scale).fontStyle(Paint.FontStyle.BOLD).color(COLOR_TEXT).strokeColor(COLOR_TEXT_OUTLINE).strokeWidth(7f).build();
    mSmallTextStyle = TextStyle.builder().fontSize(8 * scale).fontStyle(Paint.FontStyle.BOLD).color(COLOR_TEXT).strokeColor(COLOR_TEXT_OUTLINE).strokeWidth(5f).build();
    mHillshadesBitmap = getHillshadesBitmap(Color.fade(Color.DKGRAY, 0.8f));
    mPresentHillshadesBitmap = getHillshadesBitmap(Color.WHITE);
    mDateFormat = DateFormat.getDateFormat(context);
    mMapIndex.addMapStateListener(this);
    mAccountHillshades = Configuration.getHillshadesEnabled();
}
 
Example #5
Source Project: minx   Author: crazyhitty   File: DataBaseOperations.java    License: MIT License 6 votes vote down vote up
public void saveDataInDB(String title, String url, String body) {
    // ' (single apostrophe) doesn't work with sqlite database in insertion, instead of it, use ''(double apostrophe). tldr : store ' as '' otherwise it won't work
    title=title.replace("'","''");
    body=body.replace("'","''");
    Date date = new Date();
    CharSequence initTime = DateFormat.format("yyyy-MM-dd hh:mm:ss", date.getTime());
    String time = initTime.toString();
    DataBaseAdapter dbAdapter = new DataBaseAdapter(context);
    dbAdapter.createDatabase();
    dbAdapter.open();
    String query = "INSERT INTO webpage (title, url, desc, date) " +
            "VALUES ('" + title + "', '" + url + "', '" + body + "', '" + time + "')";
    dbAdapter.executeQuery(query);
    dbAdapter.close();
    Toast.makeText(context, "Data saved successfully", Toast.LENGTH_SHORT).show();
}
 
Example #6
Source Project: trekarta   Author: andreynovikov   File: TrackInformation.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void updateTrackInformation(Activity activity, Resources resources) {
    Track.TrackPoint ftp = mTrack.points.get(0);
    Track.TrackPoint ltp = mTrack.getLastPoint();

    int pointCount = mTrack.points.size();
    mPointCountView.setText(resources.getQuantityString(R.plurals.numberOfPoints, pointCount, pointCount));

    String distance = StringFormatter.distanceHP(mTrack.getDistance());
    mDistanceView.setText(distance);

    String finish_coords = StringFormatter.coordinates(ltp);
    mFinishCoordinatesView.setText(finish_coords);

    Date finishDate = new Date(ltp.time);
    mFinishDateView.setText(String.format("%s %s", DateFormat.getDateFormat(activity).format(finishDate), DateFormat.getTimeFormat(activity).format(finishDate)));

    long elapsed = (ltp.time - ftp.time) / 1000;
    String timeSpan;
    if (elapsed < 24 * 3600 * 3) { // 3 days
        timeSpan = DateUtils.formatElapsedTime(elapsed);
    } else {
        timeSpan = DateUtils.formatDateRange(activity, ftp.time, ltp.time, DateUtils.FORMAT_ABBREV_MONTH);
    }
    mTimeSpanView.setText(timeSpan);
}
 
Example #7
Source Project: NightWatch   Author: StephenBlackWasAlreadyTaken   File: BIGChart.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) {
    if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) {
        wakeLock.acquire(50);
        final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BIGChart.this);
        mTime.setText(timeFormat.format(System.currentTimeMillis()));
        showAgoRawBatt();

        if(ageLevel()<=0) {
            mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        } else {
            mSgv.setPaintFlags(mSgv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
        }

        missedReadingAlert();
        mRelativeLayout.measure(specW, specH);
        mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
                mRelativeLayout.getMeasuredHeight());
    }
}
 
Example #8
Source Project: AndroidAPS   Author: MilosKozak   File: NOChart.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) {
    if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) {
        wakeLock.acquire(50);
        final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(NOChart.this);
        mTime.setText(timeFormat.format(System.currentTimeMillis()));
        showAgeAndStatus();

        if(ageLevel()<=0) {
            mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        } else {
            mSgv.setPaintFlags(mSgv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
        }

        missedReadingAlert();
        mRelativeLayout.measure(specW, specH);
        mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
                mRelativeLayout.getMeasuredHeight());
    }
}
 
Example #9
Source Project: CSipSimple   Author: treasure-lau   File: SimpleWavRecorderHandler.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Get the file to record to for a given remote contact. This will
 * implicitly get the current date in file name.
 * 
 * @param remoteContact The remote contact name
 * @return The file to store conversation
 */
private File getRecordFile(File dir, String remoteContact, int way) {
    if (dir != null) {
        // The file name is only to have an unique identifier.
        // It should never be used to store datas as may change.
        // The app using the recording files should rely on the broadcast
        // and on callInfo instead that is reliable.
        String datePart = (String) DateFormat.format("yy-MM-dd_kkmmss", new Date());
        String remotePart = sanitizeForFile(remoteContact);
        String fileName = datePart + "_" + remotePart;
        if (way != (SipManager.BITMASK_ALL)) {
            fileName += ((way & SipManager.BITMASK_IN) == 0) ? "_out" : "_in";
        }
        File file = new File(dir.getAbsoluteFile() + File.separator
                + fileName + ".wav");
        return file;
    }
    return null;
}
 
Example #10
Source Project: xDrip-plus   Author: jamorham   File: LibreReceiver.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static List<StatusItem> megaStatus() {
    final List<StatusItem> l = new ArrayList<>();
    final Sensor sensor = Sensor.currentSensor();
    if (sensor != null) {
        l.add(new StatusItem("Libre2 Sensor", sensor.uuid + "\nStart: " + DateFormat.format("dd.MM.yyyy kk:mm", sensor.started_at)));
    }
    String lastReading ="";
    try {
        lastReading = DateFormat.format("dd.MM.yyyy kk:mm:ss", last_reading).toString();
        l.add(new StatusItem("Last Reading", lastReading));
    } catch (Exception e) {
        Log.e(TAG, "Error readlast: " + e);
    }
    if (get_engineering_mode()) {
        l.add(new StatusItem("Last Calc.", libre_calc_doku));
    }
    if (Pref.getBooleanDefaultFalse("Libre2_showSensors")) {
        l.add(new StatusItem("Sensors", Libre2Sensors()));
    }
    return l;
}
 
Example #11
Source Project: AndroidAPS   Author: MilosKozak   File: BaseWatchFace.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
public void setDateAndTime() {

        final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BaseWatchFace.this);
        if (mTime != null) {
            mTime.setText(timeFormat.format(System.currentTimeMillis()));
        }

        Date now = new Date();
        SimpleDateFormat sdfHour = new SimpleDateFormat("HH");
        SimpleDateFormat sdfMinute = new SimpleDateFormat("mm");
        sHour = sdfHour.format(now);
        sMinute = sdfMinute.format(now);

        if (mDate != null && mDay != null && mMonth != null) {
            if (sharedPrefs.getBoolean("show_date", false)) {
                SimpleDateFormat sdfDay = new SimpleDateFormat("dd");
                SimpleDateFormat sdfMonth = new SimpleDateFormat("MMM");
                mDay.setText(sdfDay.format(now));
                mMonth.setText(sdfMonth.format(now));
                mDate.setVisibility(View.VISIBLE);
            } else {
                mDate.setVisibility(View.GONE);
            }
        }
    }
 
Example #12
Source Project: xDrip   Author: NightscoutFoundation   File: BgGraphBuilder.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public synchronized void onValueSelected(int i, int i1, PointValue pointValue) {
	
	String filtered = "";
	try {
		PointValueExtended pve = (PointValueExtended) pointValue;
		if(pve.calculatedFilteredValue != -1) {
			filtered = " (" + Math.round(pve.calculatedFilteredValue*10) / 10d +")";
		}
	} catch (ClassCastException e) {
		Log.e(TAG, "Error casting a point from pointValue to PointValueExtended", e);
	}
    final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(context);
    //Won't give the exact time of the reading but the time on the grid: close enough.
    Long time = ((long)pointValue.getX())*FUZZER;
    if(tooltip!= null){
        tooltip.cancel();
    }
    tooltip = Toast.makeText(context, timeFormat.format(time)+ ": " + Math.round(pointValue.getY()*10)/ 10d + filtered, Toast.LENGTH_LONG);
    tooltip.show();
}
 
Example #13
Source Project: jmessage-android-uikit   Author: jpush   File: RecordVoiceButton.java    License: MIT License 6 votes vote down vote up
private void initDialogAndStartRecord() {
    //存放录音文件目录
    File rootDir = mContext.getFilesDir();
    String fileDir = rootDir.getAbsolutePath() + "/voice";
    File destDir = new File(fileDir);
    if (!destDir.exists()) {
        destDir.mkdirs();
    }
    //录音文件的命名格式
    myRecAudioFile = new File(fileDir,
            new DateFormat().format("yyyyMMdd_hhmmss", Calendar.getInstance(Locale.CHINA)) + ".amr");
    if (myRecAudioFile == null) {
        cancelTimer();
        stopRecording();
        Toast.makeText(mContext, mContext.getString(IdHelper.getString(mContext, "jmui_create_file_failed")),
                Toast.LENGTH_SHORT).show();
    }
    Log.i("FileCreate", "Create file success file path: " + myRecAudioFile.getAbsolutePath());
    recordIndicator = new Dialog(getContext(), IdHelper.getStyle(mContext, "jmui_record_voice_dialog"));
    recordIndicator.setContentView(IdHelper.getLayout(mContext, "jmui_dialog_record_voice"));
    mVolumeIv = (ImageView) recordIndicator.findViewById(IdHelper.getViewID(mContext, "jmui_volume_hint_iv"));
    mRecordHintTv = (TextView) recordIndicator.findViewById(IdHelper.getViewID(mContext, "jmui_record_voice_tv"));
    mRecordHintTv.setText(mContext.getString(IdHelper.getString(mContext, "jmui_move_to_cancel_hint")));
    startRecording();
    recordIndicator.show();
}
 
Example #14
Source Project: xDrip   Author: NightscoutFoundation   File: TimePickerFragment.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    final TimePickerDialog tp = new TimePickerDialog(getActivity(), this, this.hour, this.minute,
            DateFormat.is24HourFormat(getActivity()));
    if (title != null) tp.setTitle(title);
    return tp;
}
 
Example #15
Source Project: commcare-android   Author: dimagi   File: CommCareSessionService.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Show a notification while this service is running.
 */
private void showLoggedInNotification(User user) {
    //We always want this click to simply bring the live stack back to the top
    Intent callable = new Intent(this, DispatchActivity.class);
    callable.setAction("android.intent.action.MAIN");
    callable.addCategory("android.intent.category.LAUNCHER");

    // The PendingIntent to launch our activity if the user selects this notification
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, callable, 0);

    String notificationText;
    if (AppUtils.getInstalledAppRecords().size() > 1) {
        try {
            notificationText = Localization.get("notification.logged.in",
                    new String[]{Localization.get("app.display.name")});
        } catch (NoLocalizedTextException e) {
            notificationText = getString(NOTIFICATION);
        }
    } else {
        notificationText = getString(NOTIFICATION);
    }

    // Set the icon, scrolling text and timestamp
    Notification notification = new NotificationCompat.Builder(this, CommCareNoficationManager.NOTIFICATION_CHANNEL_ERRORS_ID)
            .setContentTitle(notificationText)
            .setContentText("Session Expires: " + DateFormat.format("MMM dd h:mmaa", sessionExpireDate))
            .setSmallIcon(org.commcare.dalvik.R.drawable.notification)
            .setContentIntent(contentIntent)
            .build();

    if (user != null) {
        //Send the notification.
        this.startForeground(NOTIFICATION, notification);
    }
}
 
Example #16
Source Project: white-label-event-app   Author: CodingDoug   File: TimePickerDialogFragment.java    License: Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    return new TimePickerDialog(
        getActivity(),
        this,
        hourOfDay,
        minute,
        DateFormat.is24HourFormat(getActivity())
    );
}
 
Example #17
Source Project: StyleableDateTimePicker   Author: artkoenig   File: MonthView.java    License: MIT License 5 votes vote down vote up
/**
 * Generates a description for a given time object. Since this
 * description will be spoken, the components are ordered by descending
 * specificity as DAY MONTH YEAR.
 *
 * @param day The day to generate a description for
 * @return A description of the time object
 */
protected CharSequence getItemDescription(int day) {
    mTempCalendar.set(mYear, mMonth, day);
    final CharSequence date = DateFormat.format(DATE_FORMAT,
            mTempCalendar.getTimeInMillis());

    if (day == mSelectedDay) {
        return getContext().getString(R.string.item_is_selected, date);
    }

    return date;
}
 
Example #18
Source Project: always-on-amoled   Author: rosenpin   File: DigitalS7.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void update(boolean showAmPm) {
    SimpleDateFormat sdf = DateFormat.is24HourFormat(context) ? new SimpleDateFormat("HH", Locale.getDefault()) : new SimpleDateFormat("h", Locale.getDefault());
    String hour = sdf.format(new Date());
    sdf = DateFormat.is24HourFormat(context) ? new SimpleDateFormat("mm", Locale.getDefault()) : new SimpleDateFormat("mm", Locale.getDefault());
    String minute = sdf.format(new Date());

    ((TextView) findViewById(R.id.s7_hour_tv)).setText(hour);
    ((TextView) findViewById(R.id.s7_minute_tv)).setText(minute);
    if (showAmPm)
        ((TextView) findViewById(R.id.s7_am_pm)).setText((new SimpleDateFormat("aa", Locale.getDefault()).format(new Date())));
}
 
Example #19
Source Project: tickmate   Author: lordi   File: TimePickerPreference.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected View onCreateDialogView() {
    picker = new TimePicker(getContext());

    // Set the picker to the system default 24 hour format setting
    picker.setIs24HourView(new DateFormat().is24HourFormat(this.getContext()));
    return picker;
}
 
Example #20
Source Project: Birdays   Author: Djonique   File: TimePreference.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence getSummary() {
    if (calendar == null) {
        return null;
    }
    return DateFormat.getTimeFormat(getContext()).format(new Date(calendar.getTimeInMillis()));
}
 
Example #21
Source Project: Silence   Author: SilenceIM   File: DateUtils.java    License: GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #22
Source Project: droidkaigi2016   Author: konifar   File: DateUtil.java    License: Apache License 2.0 5 votes vote down vote up
@NonNull
public static String getHourMinute(Date date) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), FORMAT_KKMM);
        return new SimpleDateFormat(pattern).format(date);
    } else {
        return String.valueOf(DateFormat.format(FORMAT_KKMM, date));
    }
}
 
Example #23
Source Project: privacy-friendly-interval-timer   Author: SecUSo   File: TimePreference.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onBindDialogView(View v) {
    super.onBindDialogView(v);
    setHour(picker, calendar.get(Calendar.HOUR_OF_DAY));
    setMinute(picker, calendar.get(Calendar.MINUTE));
    picker.setIs24HourView(DateFormat.is24HourFormat(getContext()));
}
 
Example #24
Source Project: MaterialDateTimePicker   Author: wdullaer   File: MonthView.java    License: Apache License 2.0 5 votes vote down vote up
@NonNull
private String getMonthAndYearString() {
    Locale locale = mController.getLocale();
    String pattern = "MMMM yyyy";

    if (Build.VERSION.SDK_INT < 18) pattern = getContext().getResources().getString(R.string.mdtp_date_v1_monthyear);
    else pattern = DateFormat.getBestDateTimePattern(locale, pattern);

    SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale);
    formatter.setTimeZone(mController.getTimeZone());
    formatter.applyLocalizedPattern(pattern);
    mStringBuilder.setLength(0);
    return formatter.format(mCalendar.getTime());
}
 
Example #25
Source Project: libcommon   Author: saki4510t   File: TimePickerPreferenceV7.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence getSummary() {
	if (calendar == null) {
		return super.getSummary();
	}
	return DateFormat.getTimeFormat(getContext()).format(
		new Date(calendar.getTimeInMillis()));
}
 
Example #26
Source Project: Horizontal-Calendar   Author: Mulham-Raee   File: DaysAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(DateViewHolder holder, int position) {
    Calendar day = getItem(position);
    HorizontalCalendarConfig config = horizontalCalendar.getConfig();

    final Integer selectorColor = horizontalCalendar.getConfig().getSelectorColor();
    if (selectorColor != null) {
        holder.selectionView.setBackgroundColor(selectorColor);
    }

    holder.textMiddle.setText(DateFormat.format(config.getFormatMiddleText(), day));
    holder.textMiddle.setTextSize(TypedValue.COMPLEX_UNIT_SP, config.getSizeMiddleText());

    if (config.isShowTopText()) {
        holder.textTop.setText(DateFormat.format(config.getFormatTopText(), day));
        holder.textTop.setTextSize(TypedValue.COMPLEX_UNIT_SP, config.getSizeTopText());
    } else {
        holder.textTop.setVisibility(View.GONE);
    }

    if (config.isShowBottomText()) {
        holder.textBottom.setText(DateFormat.format(config.getFormatBottomText(), day));
        holder.textBottom.setTextSize(TypedValue.COMPLEX_UNIT_SP, config.getSizeBottomText());
    } else {
        holder.textBottom.setVisibility(View.GONE);
    }

    showEvents(holder, day);
    applyStyle(holder, day, position);

}
 
Example #27
Source Project: GravityBox   Author: WrBug   File: PieSysInfo.java    License: Apache License 2.0 5 votes vote down vote up
private void updateData() {
    mDateText = DateFormat.getMediumDateFormat(mContext).format(new Date()).toUpperCase(Locale.getDefault());
    mNetworkState = mController.getOperatorState();
    if (mNetworkState != null) {
        mNetworkState = mNetworkState.toUpperCase(Locale.getDefault());
    }
    mWifiSsid = getWifiSsid().toUpperCase(Locale.getDefault());
    mBatteryLevelReadable = mController.getBatteryLevel().toUpperCase(Locale.getDefault());
}
 
Example #28
Source Project: geoar-app   Author: 52North   File: DateTimeSettingsViewField.java    License: Apache License 2.0 5 votes vote down vote up
private void updateViews() {
	if (timeEditText != null)
		timeEditText.setText(selectedValue != null ? DateFormat
				.getTimeFormat(context).format(selectedValue.getTime())
				: "");

	if (dateEditText != null)
		dateEditText.setText(selectedValue != null ? DateFormat
				.getDateFormat(context).format(selectedValue.getTime())
				: "");
}
 
Example #29
Source Project: droidkaigi2016   Author: konifar   File: DateUtil.java    License: Apache License 2.0 5 votes vote down vote up
@NonNull
public static String getMonthDate(Date date, Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), FORMAT_MMDD);
        return new SimpleDateFormat(pattern).format(date);
    } else {
        int flag = DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_NO_YEAR;
        return DateUtils.formatDateTime(context, date.getTime(), flag);
    }
}
 
Example #30
Source Project: DateTimePicker   Author: Gericop   File: SimpleMonthView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Generates a description for a given virtual view.
 *
 * @param id the day to generate a description for
 * @return a description of the virtual view
 */
private CharSequence getDayDescription(int id) {
    if (isValidDayOfMonth(id)) {
        mTempCalendar.set(mYear, mMonth, id);
        return DateFormat.format(DATE_FORMAT, mTempCalendar.getTimeInMillis());
    }

    return "";
}