android.text.format.DateFormat#getDateFormat ( )源码实例Demo

下面列出了android.text.format.DateFormat#getDateFormat ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: trekarta   文件: MapCoverageLayer.java
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();
}
 
源代码2 项目: Dashchan   文件: BackupManager.java
public static LinkedHashMap<File, String> getAvailableBackups(Context context) {
	LinkedHashMap<File, String> backups = new LinkedHashMap<>();
	File[] files = Preferences.getDownloadDirectory().listFiles();
	if (files != null) {
		Arrays.sort(files, COMPARATOR);
		java.text.DateFormat timeFormat = DateFormat.getTimeFormat(context);
		java.text.DateFormat dateFormat = DateFormat.getDateFormat(context);
		for (File file : files) {
			Matcher matcher = NAME_PATTERN.matcher(file.getName());
			if (matcher.matches()) {
				long date = Long.parseLong(matcher.group(1));
				String dateString = dateFormat.format(date) + " " + timeFormat.format(date);
				backups.put(file, dateString);
			}
		}
	}
	return backups;
}
 
源代码3 项目: microMathematics   文件: AdapterBaseImpl.java
protected AdapterBaseImpl(Context ctx_, int mode_)
{
    ctx = ctx_;
    mode = mode_;
    mInflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    localeDateFormat = DateFormat.getDateFormat(ctx);
    localeTimeFormat = DateFormat.getTimeFormat(ctx);
    density = ctx.getResources().getDisplayMetrics().density;
}
 
源代码4 项目: wear-os-samples   文件: DigitalWatchFaceService.java
private void initFormats() {
    mDayOfWeekFormat = new SimpleDateFormat("EEEE", Locale.getDefault());
    mDayOfWeekFormat.setCalendar(mCalendar);
    mDateFormat = DateFormat.getDateFormat(DigitalWatchFaceService.this);
    mDateFormat.setCalendar(mCalendar);
}
 
源代码5 项目: delion   文件: CertificateViewer.java
private void addCertificateDetails(Certificate cert, byte[] sha256Digest, byte[] sha1Digest) {
    LinearLayout certificateView = new LinearLayout(mContext);
    mViews.add(certificateView);
    certificateView.setOrientation(LinearLayout.VERTICAL);

    X509Certificate x509 = (X509Certificate) cert;
    SslCertificate sslCert = new SslCertificate(x509);

    mTitles.add(sslCert.getIssuedTo().getCName());

    addSectionTitle(certificateView, nativeGetCertIssuedToText());
    addItem(certificateView, nativeGetCertInfoCommonNameText(),
            sslCert.getIssuedTo().getCName());
    addItem(certificateView, nativeGetCertInfoOrganizationText(),
            sslCert.getIssuedTo().getOName());
    addItem(certificateView, nativeGetCertInfoOrganizationUnitText(),
            sslCert.getIssuedTo().getUName());
    addItem(certificateView, nativeGetCertInfoSerialNumberText(),
            formatBytes(x509.getSerialNumber().toByteArray(), ':'));

    addSectionTitle(certificateView, nativeGetCertIssuedByText());
    addItem(certificateView, nativeGetCertInfoCommonNameText(),
            sslCert.getIssuedBy().getCName());
    addItem(certificateView, nativeGetCertInfoOrganizationText(),
            sslCert.getIssuedBy().getOName());
    addItem(certificateView, nativeGetCertInfoOrganizationUnitText(),
            sslCert.getIssuedBy().getUName());

    addSectionTitle(certificateView, nativeGetCertValidityText());
    java.text.DateFormat dateFormat = DateFormat.getDateFormat(mContext);
    addItem(certificateView, nativeGetCertIssuedOnText(),
            dateFormat.format(sslCert.getValidNotBeforeDate()));
    addItem(certificateView, nativeGetCertExpiresOnText(),
            dateFormat.format(sslCert.getValidNotAfterDate()));

    addSectionTitle(certificateView, nativeGetCertFingerprintsText());
    addItem(certificateView, nativeGetCertSHA256FingerprintText(),
            formatBytes(sha256Digest, ' '));
    addItem(certificateView, nativeGetCertSHA1FingerprintText(),
            formatBytes(sha1Digest, ' '));
}
 
源代码6 项目: AndroidChromium   文件: CertificateViewer.java
private void addCertificateDetails(Certificate cert, byte[] sha256Digest, byte[] sha1Digest) {
    LinearLayout certificateView = new LinearLayout(mContext);
    mViews.add(certificateView);
    certificateView.setOrientation(LinearLayout.VERTICAL);

    X509Certificate x509 = (X509Certificate) cert;
    SslCertificate sslCert = new SslCertificate(x509);

    mTitles.add(sslCert.getIssuedTo().getCName());

    addSectionTitle(certificateView, nativeGetCertIssuedToText());
    addItem(certificateView, nativeGetCertInfoCommonNameText(),
            sslCert.getIssuedTo().getCName());
    addItem(certificateView, nativeGetCertInfoOrganizationText(),
            sslCert.getIssuedTo().getOName());
    addItem(certificateView, nativeGetCertInfoOrganizationUnitText(),
            sslCert.getIssuedTo().getUName());
    addItem(certificateView, nativeGetCertInfoSerialNumberText(),
            formatBytes(x509.getSerialNumber().toByteArray(), ':'));

    addSectionTitle(certificateView, nativeGetCertIssuedByText());
    addItem(certificateView, nativeGetCertInfoCommonNameText(),
            sslCert.getIssuedBy().getCName());
    addItem(certificateView, nativeGetCertInfoOrganizationText(),
            sslCert.getIssuedBy().getOName());
    addItem(certificateView, nativeGetCertInfoOrganizationUnitText(),
            sslCert.getIssuedBy().getUName());

    addSectionTitle(certificateView, nativeGetCertValidityText());
    java.text.DateFormat dateFormat = DateFormat.getDateFormat(mContext);
    addItem(certificateView, nativeGetCertIssuedOnText(),
            dateFormat.format(sslCert.getValidNotBeforeDate()));
    addItem(certificateView, nativeGetCertExpiresOnText(),
            dateFormat.format(sslCert.getValidNotAfterDate()));

    addSectionTitle(certificateView, nativeGetCertFingerprintsText());
    addItem(certificateView, nativeGetCertSHA256FingerprintText(),
            formatBytes(sha256Digest, ' '));
    addItem(certificateView, nativeGetCertSHA1FingerprintText(),
            formatBytes(sha1Digest, ' '));
}
 
源代码7 项目: openScale   文件: OpenScale.java
public int addScaleMeasurement(final ScaleMeasurement scaleMeasurement, boolean silent) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

    // Check user id and do a smart user assign if option is enabled
    if (scaleMeasurement.getUserId() == -1) {
        if (prefs.getBoolean("smartUserAssign", false)) {
            scaleMeasurement.setUserId(getSmartUserAssignment(scaleMeasurement.getWeight(), 15.0f));
        } else {
            scaleMeasurement.setUserId(getSelectedScaleUser().getId());
        }

        // don't add scale data if no user is selected
        if (scaleMeasurement.getUserId() == -1) {
            Timber.e("to be added measurement are thrown away because no user is selected");
            return -1;
        }
    }

    // Assisted weighing
    if (getScaleUser(scaleMeasurement.getUserId()).isAssistedWeighing()) {
        int assistedWeighingRefUserId = prefs.getInt("assistedWeighingRefUserId", -1);
        if (assistedWeighingRefUserId != -1) {
            ScaleMeasurement lastRefScaleMeasurement = getLastScaleMeasurement(assistedWeighingRefUserId);

            if (lastRefScaleMeasurement != null) {
                float refWeight = lastRefScaleMeasurement.getWeight();
                float diffToRef = scaleMeasurement.getWeight() - refWeight;
                scaleMeasurement.setWeight(diffToRef);
            }
        } else {
            Timber.e("assisted weighing reference user id is -1");
        }
    }

    // Calculate the amputation correction factor for the weight, if available
    scaleMeasurement.setWeight((scaleMeasurement.getWeight() * 100.0f) / getScaleUser(scaleMeasurement.getUserId()).getAmputationCorrectionFactor());

    // If option is enabled then calculate body measurements from generic formulas
    MeasurementViewSettings settings = new MeasurementViewSettings(prefs, WaterMeasurementView.KEY);
    if (settings.isEnabled() && settings.isEstimationEnabled()) {
        EstimatedWaterMetric waterMetric = EstimatedWaterMetric.getEstimatedMetric(
                EstimatedWaterMetric.FORMULA.valueOf(settings.getEstimationFormula()));
        scaleMeasurement.setWater(waterMetric.getWater(getScaleUser(scaleMeasurement.getUserId()), scaleMeasurement));
    }

    settings = new MeasurementViewSettings(prefs, FatMeasurementView.KEY);
    if (settings.isEnabled() && settings.isEstimationEnabled()) {
        EstimatedFatMetric fatMetric = EstimatedFatMetric.getEstimatedMetric(
                EstimatedFatMetric.FORMULA.valueOf(settings.getEstimationFormula()));
        scaleMeasurement.setFat(fatMetric.getFat(getScaleUser(scaleMeasurement.getUserId()), scaleMeasurement));
    }

    // Must be after fat estimation as one formula is based on fat
    settings = new MeasurementViewSettings(prefs, LBMMeasurementView.KEY);
    if (settings.isEnabled() && settings.isEstimationEnabled()) {
        EstimatedLBMMetric lbmMetric = EstimatedLBMMetric.getEstimatedMetric(
                EstimatedLBMMetric.FORMULA.valueOf(settings.getEstimationFormula()));
        scaleMeasurement.setLbm(lbmMetric.getLBM(getScaleUser(scaleMeasurement.getUserId()), scaleMeasurement));
    }

    // Insert measurement into the database, check return if it was successful inserted
    if (measurementDAO.insert(scaleMeasurement) != -1) {
        Timber.d("Added measurement: %s", scaleMeasurement);
        if (!silent) {
            ScaleUser scaleUser = getScaleUser(scaleMeasurement.getUserId());

            final java.text.DateFormat dateFormat = DateFormat.getDateFormat(context);
            final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(context);
            final Date dateTime = scaleMeasurement.getDateTime();

            final Converters.WeightUnit unit = scaleUser.getScaleUnit();

            String infoText = String.format(context.getString(R.string.info_new_data_added),
                    Converters.fromKilogram(scaleMeasurement.getWeight(), unit), unit.toString(),
                    dateFormat.format(dateTime) + " " + timeFormat.format(dateTime),
                    scaleUser.getUserName());
            runUiToastMsg(infoText);
        }

        syncInsertMeasurement(scaleMeasurement);
        alarmHandler.entryChanged(context, scaleMeasurement);
        triggerWidgetUpdate();
    } else {
        Timber.d("to be added measurement is thrown away because measurement with the same date and time already exist");
        if (!silent) {
            runUiToastMsg(context.getString(R.string.info_new_data_duplicated));
        }
    }

    return scaleMeasurement.getUserId();
}
 
源代码8 项目: sana.mobile   文件: CustomDatePicker.java
private void reorderPickers(String[] months) {
    java.text.DateFormat format;
    String order;

    /*
     * If the user is in a locale where the medium date format is
     * still numeric (Japanese and Czech, for example), respect
     * the date format order setting.  Otherwise, use the order
     * that the locale says is appropriate for a spelled-out date.
     */

    if (months[0].startsWith("1")) {
        format = DateFormat.getDateFormat(getContext());
    } else {
        format = DateFormat.getMediumDateFormat(getContext());
    }

    if (format instanceof SimpleDateFormat) {
        order = ((SimpleDateFormat) format).toPattern();
    } else {
        // Shouldn't happen, but just in case.
        order = new String(DateFormat.getDateFormatOrder(getContext()));
    }

    /* Remove the 3 pickers from their parent and then add them back in the
     * required order.
     */
    LinearLayout parent = (LinearLayout) findViewById(R.id.parent);
    parent.removeAllViews();

    boolean quoted = false;
    boolean didDay = false, didMonth = false, didYear = false;

    for (int i = 0; i < order.length(); i++) {
        char c = order.charAt(i);

        if (c == '\'') {
            quoted = !quoted;
        }

        if (!quoted) {
            if (c == DATE && !didDay) {
                parent.addView(mDayPicker);
                didDay = true;
            } else if ((c == MONTH || c == 'L') && !didMonth) {
                parent.addView(mMonthPicker);
                didMonth = true;
            } else if (c == YEAR && !didYear) {
                parent.addView(mYearPicker);
                didYear = true;
            }
        }
    }

    // Shouldn't happen, but just in case.
    if (!didMonth) {
        parent.addView(mMonthPicker);
    }
    if (!didDay) {
        parent.addView(mDayPicker);
    }
    if (!didYear) {
        parent.addView(mYearPicker);
    }
}
 
源代码9 项目: android-chromium   文件: CertificateViewer.java
private void addCertificateDetails(Certificate cert, byte[] sha256Digest, byte[] sha1Digest) {
    LinearLayout certificateView = new LinearLayout(mContext);
    mViews.add(certificateView);
    certificateView.setOrientation(LinearLayout.VERTICAL);

    X509Certificate x509 = (X509Certificate) cert;
    SslCertificate sslCert = new SslCertificate(x509);

    mTitles.add(sslCert.getIssuedTo().getCName());

    addSectionTitle(certificateView, nativeGetCertIssuedToText());
    addItem(certificateView, nativeGetCertInfoCommonNameText(),
            sslCert.getIssuedTo().getCName());
    addItem(certificateView, nativeGetCertInfoOrganizationText(),
            sslCert.getIssuedTo().getOName());
    addItem(certificateView, nativeGetCertInfoOrganizationUnitText(),
            sslCert.getIssuedTo().getUName());
    addItem(certificateView, nativeGetCertInfoSerialNumberText(),
            formatBytes(x509.getSerialNumber().toByteArray(), ':'));

    addSectionTitle(certificateView, nativeGetCertIssuedByText());
    addItem(certificateView, nativeGetCertInfoCommonNameText(),
            sslCert.getIssuedBy().getCName());
    addItem(certificateView, nativeGetCertInfoOrganizationText(),
            sslCert.getIssuedBy().getOName());
    addItem(certificateView, nativeGetCertInfoOrganizationUnitText(),
            sslCert.getIssuedBy().getUName());

    addSectionTitle(certificateView, nativeGetCertValidityText());
    java.text.DateFormat dateFormat = DateFormat.getDateFormat(mContext);
    addItem(certificateView, nativeGetCertIssuedOnText(),
            dateFormat.format(sslCert.getValidNotBeforeDate()));
    addItem(certificateView, nativeGetCertExpiresOnText(),
            dateFormat.format(sslCert.getValidNotAfterDate()));

    addSectionTitle(certificateView, nativeGetCertFingerprintsText());
    addItem(certificateView, nativeGetCertSHA256FingerprintText(),
            formatBytes(sha256Digest, ' '));
    addItem(certificateView, nativeGetCertSHA1FingerprintText(),
            formatBytes(sha1Digest, ' '));
}
 
源代码10 项目: android-chromium   文件: CertificateViewer.java
private void addCertificateDetails(Certificate cert, byte[] sha256Digest, byte[] sha1Digest) {
    LinearLayout certificateView = new LinearLayout(mContext);
    mViews.add(certificateView);
    certificateView.setOrientation(LinearLayout.VERTICAL);

    X509Certificate x509 = (X509Certificate) cert;
    SslCertificate sslCert = new SslCertificate(x509);

    mTitles.add(sslCert.getIssuedTo().getCName());

    addSectionTitle(certificateView, nativeGetCertIssuedToText());
    addItem(certificateView, nativeGetCertInfoCommonNameText(),
            sslCert.getIssuedTo().getCName());
    addItem(certificateView, nativeGetCertInfoOrganizationText(),
            sslCert.getIssuedTo().getOName());
    addItem(certificateView, nativeGetCertInfoOrganizationUnitText(),
            sslCert.getIssuedTo().getUName());
    addItem(certificateView, nativeGetCertInfoSerialNumberText(),
            formatBytes(x509.getSerialNumber().toByteArray(), ':'));

    addSectionTitle(certificateView, nativeGetCertIssuedByText());
    addItem(certificateView, nativeGetCertInfoCommonNameText(),
            sslCert.getIssuedBy().getCName());
    addItem(certificateView, nativeGetCertInfoOrganizationText(),
            sslCert.getIssuedBy().getOName());
    addItem(certificateView, nativeGetCertInfoOrganizationUnitText(),
            sslCert.getIssuedBy().getUName());

    addSectionTitle(certificateView, nativeGetCertValidityText());
    java.text.DateFormat dateFormat = DateFormat.getDateFormat(mContext);
    addItem(certificateView, nativeGetCertIssuedOnText(),
            dateFormat.format(sslCert.getValidNotBeforeDate()));
    addItem(certificateView, nativeGetCertExpiresOnText(),
            dateFormat.format(sslCert.getValidNotAfterDate()));

    addSectionTitle(certificateView, nativeGetCertFingerprintsText());
    addItem(certificateView, nativeGetCertSHA256FingerprintText(),
            formatBytes(sha256Digest, ' '));
    addItem(certificateView, nativeGetCertSHA1FingerprintText(),
            formatBytes(sha1Digest, ' '));
}