Example usage for java.text DateFormat MEDIUM

List of usage examples for java.text DateFormat MEDIUM

Introduction

In this page you can find the example usage for java.text DateFormat MEDIUM.

Prototype

int MEDIUM

To view the source code for java.text DateFormat MEDIUM.

Click Source Link

Document

Constant for medium style pattern.

Usage

From source file:de.greenrobot.daoexample.NoteActivity.java

private void addNote() {
    String noteText = editText.getText().toString();
    editText.setText("");

    final DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
    String comment = "Added on " + df.format(new Date());
    Note note = new Note(null, noteText, comment, new Date());
    noteDao.insert(note);//from  w  w  w  .ja va  2 s  . c o  m
    Log.d("DaoExample", "Inserted new note, ID: " + note.getId());
    cursor.requery();
}

From source file:org.telscenter.sail.webapp.presentation.web.controllers.student.brainstorm.XMLBrainstorm.java

public static String getXMLRevision(Revision revision) {
    Date timestamp = revision.getTimestamp();
    String formattedTime = DateFormat.getTimeInstance(DateFormat.SHORT).format(timestamp);

    String formattedDate = DateFormat.getDateInstance(DateFormat.MEDIUM).format(timestamp);

    String xmlDisplayname = "";
    if (revision.getDisplayname() != null && !revision.getDisplayname().equals("")) {
        xmlDisplayname = "<displayname>" + revision.getDisplayname() + "</displayname>";
    }//from   w  w w .j a v a2  s . c o m
    String XMLRevision = "<revision><id>" + revision.getId() + "</id><timestamp>" + formattedTime + " "
            + formattedDate + "</timestamp>" + xmlDisplayname + "<body>"
            + StringEscapeUtils.escapeHtml(revision.getBody()) + "</body></revision>";
    return XMLRevision;
}

From source file:eu.esdihumboldt.hale.io.html.HtmlMappingExporter.java

@Override
protected IOReport execute(ProgressIndicator progress, IOReporter reporter)
        throws IOProviderConfigurationException, IOException {
    this.reporter = reporter;

    context = new VelocityContext();
    cellIds = new Identifiers<Cell>(Cell.class, false);

    alignment = getAlignment();//w w  w. j av a  2 s .  c o m

    URL headlinePath = this.getClass().getResource("bg-headline.png"); //$NON-NLS-1$
    URL cssPath = this.getClass().getResource("style.css"); //$NON-NLS-1$
    URL linkPath = this.getClass().getResource("int_link.png"); //$NON-NLS-1$
    URL tooltipIcon = this.getClass().getResource("tooltip.gif"); //$NON-NLS-1$
    final String filesSubDir = FilenameUtils
            .removeExtension(FilenameUtils.getName(getTarget().getLocation().getPath())) + "_files"; //$NON-NLS-1$
    final File filesDir = new File(FilenameUtils.getFullPath(getTarget().getLocation().getPath()), filesSubDir);

    filesDir.mkdirs();
    context.put(FILE_DIRECTORY, filesSubDir);

    try {
        init();
    } catch (Exception e) {
        return reportError(reporter, "Initializing error", e);
    }
    File cssOutputFile = new File(filesDir, "style.css");
    FileUtils.copyFile(getInputFile(cssPath), cssOutputFile);

    // create headline picture
    File headlineOutputFile = new File(filesDir, "bg-headline.png"); //$NON-NLS-1$
    FileUtils.copyFile(getInputFile(headlinePath), headlineOutputFile);

    File linkOutputFile = new File(filesDir, "int_link.png"); //$NON-NLS-1$
    FileUtils.copyFile(getInputFile(linkPath), linkOutputFile);

    File tooltipIconFile = new File(filesDir, "tooltip.png"); //$NON-NLS-1$
    FileUtils.copyFile(getInputFile(tooltipIcon), tooltipIconFile);

    File htmlExportFile = new File(getTarget().getLocation().getPath());
    if (projectInfo != null) {
        Date date = new Date();
        DateFormat dfm = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT);

        // associate variables with information data
        String exportDate = dfm.format(date);
        context.put(EXPORT_DATE, exportDate);

        if (projectInfo.getCreated() != null) {
            String created = dfm.format(projectInfo.getCreated());
            context.put(CREATED_DATE, created);
        }

        context.put(PROJECT_INFO, projectInfo);
    }

    if (alignment != null) {
        Collection<TypeCellInfo> typeCellInfos = new ArrayList<TypeCellInfo>();
        Collection<? extends Cell> cells = alignment.getTypeCells();
        Iterator<? extends Cell> it = cells.iterator();
        while (it.hasNext()) {
            final Cell cell = it.next();
            // this is the collection of type cell info
            TypeCellInfo typeCellInfo = new TypeCellInfo(cell, alignment, cellIds, filesSubDir);
            typeCellInfos.add(typeCellInfo);
        }
        // put the full collection of type cell info to the context (for the
        // template)
        context.put(TYPE_CELL_INFOS, typeCellInfos);
        createImages(filesDir);
    }

    context.put(TOOLTIP, getParameter(TOOLTIP).as(boolean.class));

    Template template;
    try {
        template = velocityEngine.getTemplate(templateFile.getName(), "UTF-8");
    } catch (Exception e) {
        return reportError(reporter, "Could not load template", e);
    }

    FileWriter fileWriter = new FileWriter(htmlExportFile);
    template.merge(context, fileWriter);
    fileWriter.close();

    reporter.setSuccess(true);
    return reporter;
}

From source file:org.openvpms.web.resource.i18n.format.DateFormatter.java

/**
 * Returns a date-time format./*  www .j a  va2  s . c om*/
 *
 * @param edit if {@code true} return a format for editing otherwise
 * @return a format for viewing date-times.
 */
public static DateFormat getDateTimeFormat(boolean edit) {
    DateFormat format;
    Locale locale = Messages.getLocale();
    if (edit) {
        // specify SHORT style for dates when parsing, so that 2 digit years
        // are handled correctly
        format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale);
    } else if (DATE_TIME_VIEW_PATTERN != null) {
        format = new SimpleDateFormat(DATE_TIME_VIEW_PATTERN, locale);
    } else {
        format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, locale);
    }
    return format;
}

From source file:net.naonedbus.fragment.impl.ItineraireFragment.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mDateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT);
    mIconPadding = getResources().getDimensionPixelSize(R.dimen.itinerary_icon_padding);

    if (savedInstanceState != null) {
        mFromLocation.set((Location) savedInstanceState.getParcelable(BUNDLE_LOCATION_FROM));
        mToLocation.set((Location) savedInstanceState.getParcelable(BUNDLE_LOCATION_TO));

        mDateTime.setMillis(savedInstanceState.getLong(BUNDLE_DATE_TIME));
        mArriveBy = savedInstanceState.getBoolean(BUNDLE_ARRIVE_BY);
        mIconFromResId = savedInstanceState.getInt(BUNDLE_ICON_FROM);
        mIconToResId = savedInstanceState.getInt(BUNDLE_ICON_TO);
        mIconFromColor = savedInstanceState.getInt(BUNDLE_COLOR_FROM);
        mIconToColor = savedInstanceState.getInt(BUNDLE_COLOR_TO);

        final List<Parcelable> results = savedInstanceState.getParcelableArrayList(BUNDLE_RESULTS);
        for (final Parcelable parcelable : results) {
            mItineraryWrappers.add((ItineraryWrapper) parcelable);
        }//from w  ww  .j ava  2  s  .c  o  m

    }
}

From source file:org.sakaiproject.time.impl.BasicTimeService.java

/**
 * Final initialization, once all dependencies are set.
 *//*from  www. java  2s . co m*/
public void init() {
    /** The time zone for our GMT times. */
    M_tz = TimeZone.getTimeZone("GMT");

    M_log.info("init()");

    /**
     * a calendar to clone for GMT time construction
     */
    M_GCal = getCalendar(M_tz, 0, 0, 0, 0, 0, 0, 0);

    // Note: formatting for GMT time representations
    M_fmtA = (DateFormat) (new SimpleDateFormat("yyyyMMddHHmmssSSS"));
    M_fmtB = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT);
    M_fmtC = DateFormat.getTimeInstance(DateFormat.SHORT);
    M_fmtD = DateFormat.getDateInstance(DateFormat.MEDIUM);
    M_fmtE = (DateFormat) (new SimpleDateFormat("yyyyMMddHHmmss"));
    M_fmtG = (DateFormat) (new SimpleDateFormat("yyyy/DDD/HH/")); // that's year, day of year, hour

    M_fmtA.setTimeZone(M_tz);
    M_fmtB.setTimeZone(M_tz);
    M_fmtC.setTimeZone(M_tz);
    M_fmtD.setTimeZone(M_tz);
    M_fmtE.setTimeZone(M_tz);
    M_fmtG.setTimeZone(M_tz);

    //register the Cache
    M_userTzCache = memoryService.newCache("org.sakaiproject.time.impl.BasicTimeService.userTimezoneCache");
}

From source file:com.kth.baasio.baassample.utils.EtcUtils.java

public static String getSimpleDateString(long millis) {
    String time = null;//ww w  . j av a2s .co m

    if (Locale.getDefault().equals(Locale.KOREA) || Locale.getDefault().equals(Locale.KOREAN)) {
        SimpleDateFormat formatter = new SimpleDateFormat("M d? a h mm", Locale.getDefault());
        time = formatter.format(new Date(millis));
    } else {
        time = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, Locale.getDefault())
                .format(new Date(millis));
    }

    return time;
}

From source file:com.mobicage.rogerthat.FriendsLocationActivity.java

private void displayLocations() {
    T.UI();//from  ww  w  .ja va  2s.c o m
    mLoadingProgressbar.setVisibility(View.GONE);
    mLoadingLayout.setVisibility(View.GONE);
    mFriendMap.setVisibility(View.VISIBLE);
    // Calculate bounds
    double maxLat = Double.MIN_VALUE;
    double minLat = Double.MAX_VALUE;
    double maxLon = Double.MIN_VALUE;
    double minLon = Double.MAX_VALUE;
    for (LocationResultRequestTO fl : mLocations) {
        if (fl.location.latitude > maxLat)
            maxLat = fl.location.latitude;
        if (fl.location.latitude < minLat)
            minLat = fl.location.latitude;
        if (fl.location.longitude > maxLon)
            maxLon = fl.location.longitude;
        if (fl.location.longitude < minLon)
            minLon = fl.location.longitude;
    }
    mFriendMap.getController().zoomToSpan((int) ((maxLat - minLat)), (int) ((maxLon - minLon)));
    GeoPoint center = new GeoPoint((int) ((maxLat + minLat) / 2), (int) ((maxLon + minLon) / 2));
    mFriendMap.getController().setCenter(center);
    for (LocationResultRequestTO fl : mLocations) {
        if (mAdded.contains(fl.friend))
            continue;
        mAdded.add(fl.friend);

        if (fl.friend.equals(mMyIdentity.getEmail())) {
            DrawableItemizedOverlay overlay = new DrawableItemizedOverlay(getAvatar(mMyIdentity), this);
            GeoPoint point = new GeoPoint((int) (fl.location.latitude), (int) (fl.location.longitude));
            Date date = new Date(fl.location.timestamp * 1000);
            OverlayItem overlayitem = new OverlayItem(point, mMyIdentity.getName(),
                    getString(R.string.friend_map_marker,
                            DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(date),
                            fl.location.accuracy));
            overlay.addOverlay(overlayitem);
            mFriendMap.getOverlays().add(overlay);
        } else {
            Friend friend = mFriendsPlugin.getStore().getExistingFriend(fl.friend);

            DrawableItemizedOverlay overlay = new DrawableItemizedOverlay(getAvatar(friend), this);
            GeoPoint point = new GeoPoint((int) (fl.location.latitude), (int) (fl.location.longitude));
            Date date = new Date(fl.location.timestamp * 1000);
            OverlayItem overlayitem = new OverlayItem(point, friend.getDisplayName(),
                    getString(R.string.friend_map_marker,
                            DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(date),
                            fl.location.accuracy));
            overlay.addOverlay(overlayitem);
            mFriendMap.getOverlays().add(overlay);
        }
    }
    if (mAdded.size() == 1 && mAdded.get(0).equals(mMyIdentity.getEmail()))
        UIUtils.showLongToast(this,
                getString(R.string.your_location_displayed_friend_have_contacted_for_their_location));
}

From source file:com.codeblue.service.impl.admin.AdministratorServiceImpl.java

public String dateConvert(Date date) {
    return DateFormat.getDateInstance(DateFormat.MEDIUM).format(date);
}

From source file:org.akvo.caddisfly.sensor.colorimetry.liquid.CalibrateListActivity.java

private void loadDetails() {

    TestInfo testInfo = CaddisflyApp.getApp().getCurrentTestInfo();

    testInfo.setCalibrationDate(PreferencesUtil.getLong(this, testInfo.getId(), R.string.calibrationDateKey));

    if (testInfo.getCalibrationDate() >= 0) {
        textSubtitle1.setText(//from   w  w  w  .  ja  v  a 2s  .  c  o  m
                DateFormat.getDateInstance(DateFormat.MEDIUM).format(new Date(testInfo.getCalibrationDate())));
    }

    testInfo.setExpiryDate(PreferencesUtil.getLong(this, testInfo.getId(), R.string.calibrationExpiryDateKey));

    if (testInfo.getExpiryDate() >= 0) {
        textSubtitle2.setText(String.format("%s: %s", getString(R.string.expires),
                DateFormat.getDateInstance(DateFormat.MEDIUM).format(new Date(testInfo.getExpiryDate()))));
    }

    testInfo.setBatchNumber(PreferencesUtil.getString(this, testInfo.getId(), R.string.batchNumberKey, ""));

    textSubtitle.setText(testInfo.getBatchNumber());

    CalibrateListFragment calibrateListFragment = (CalibrateListFragment) getSupportFragmentManager()
            .findFragmentById(R.id.fragmentCalibrateList);

    if (calibrateListFragment != null) {
        calibrateListFragment.refresh();
    }
}