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:org.polymap.p4.data.importer.prompts.SchemaNamePrompt.java

/**
 * Retype the given features: set schema name to current {@link #selection}, add
 * description the schema, set feature id.
 *
 * @param features//from w w  w . j  av a  2 s  . c om
 * @param sourceDescription The description to be set in the adapted {@link FeatureType}.
 * @return {@link RetypingFeatureCollection}
 */
public FeatureCollection retypeFeatures(SimpleFeatureCollection features, String sourceDescription) {
    // no maxResults restriction
    SimpleFeatureType original = features.getSchema();

    SimpleFeatureTypeBuilder ftb = new SimpleFeatureTypeBuilder();
    ftb.init(original);
    ftb.setName(selection);
    DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, RWT.getLocale());
    ftb.setDescription(SimpleInternationalString
            .wrap("Imported from " + sourceDescription + " on " + df.format(new Date())));
    SimpleFeatureType schema = ftb.buildFeatureType();

    return new RetypingFeatureCollection<SimpleFeatureType, SimpleFeature>(features, schema) {
        @Override
        protected SimpleFeature retype(SimpleFeature feature) {
            SimpleFeatureBuilder fb = new SimpleFeatureBuilder(getSchema());
            fb.init(feature);
            String fid = schema.getName().getLocalPart() + "." + RFeatureStore.idcount.getAndIncrement();
            return fb.buildFeature(fid);
        }
    };
}

From source file:org.olat.core.util.Formatter.java

License:asdf

/**
 * formats the given time period so it is friendly to read
 * /*ww w .j  a v a 2 s  .  c  om*/
 * @param d the date
 * @return a String with the formatted time
 */
public String formatTime(Date d) {
    DateFormat df = DateFormat.getTimeInstance(DateFormat.MEDIUM, locale);
    df.setLenient(false);
    String da = df.format(d);
    return da;
}

From source file:pl.exsio.ca.module.config.groups.AssignmentsDataTable.java

@Override
protected void doInit() {
    super.doInit();
    if (this.group == null) {
        this.setEnabled(false);
    }/*w w  w  .java2s.  co m*/
    this.setHeight("250px");
    Converter dateConverter = new StringToDateConverter() {
        @Override
        protected DateFormat getFormat(Locale locale) {
            return DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
        }
    };
    this.dataComponent.setConverter("date", dateConverter);
}

From source file:pl.exsio.ca.module.terrain.evidence.AssignmentsDataTable.java

@Override
protected void doInit() {
    super.doInit();
    if (this.terrain == null) {
        this.setEnabled(false);
    }/*from w  ww .  j av  a  2 s . c  o  m*/
    this.setHeight("250px");
    Converter dateConverter = new StringToDateConverter() {
        @Override
        protected DateFormat getFormat(Locale locale) {
            return DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
        }
    };
    this.dataComponent.setConverter("startDate", dateConverter);
    this.dataComponent.setConverter("endDate", dateConverter);
}

From source file:es.warp.killthedj.track.AvailableTrack.java

public String getDuration() {
    // TODO library like duration from ruby
    return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(getTime());
}

From source file:DateUtil.java

/**
 * Formats given time according to specified locale and <code>DateFormat.MEDIUM</code> style
 *
 * @param time   Time to convert/*ww w. j a  va  2s .c  om*/
 * @param locale Locale to use for formatting time
 * @return String representation of time according to given locale and <code>DateFormat.MEDIUM</code> style
 * @see java.text.DateFormat
 * @see java.text.DateFormat#MEDIUM
 */
public static String formatTime(Date time, Locale locale) {
    return formatTime(time, locale, DateFormat.MEDIUM);
}

From source file:com.stefanbrenner.droplet.model.internal.DropletContext.java

@Override
public void addLoggingMessage(final String message) {
    String oldValue = getLoggingMessages();
    loggingMessages = new ArrayList<String>(loggingMessages);

    // add timestamp to message
    DateFormat format = DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.getDefault());
    String timestamp = format.format(new Date(System.currentTimeMillis()));
    String logEntry = timestamp + ": " + message; //$NON-NLS-1$

    loggingMessages.add(logEntry);/*from   ww  w. ja v  a 2 s  . c  o  m*/

    firePropertyChange(IDropletContext.PROPERTY_LOGGING, oldValue, getLoggingMessages());
}

From source file:org.sakaiproject.evaluation.tool.renderers.AdminBoxRenderer.java

public void init() {
    df = DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
}

From source file:zlyh.dmitry.recaller.services.RecordService.java

private void saveSQL(long time_end, int was_incoming) {
    if (file == null || time_end == -1 || time_start == -1) {
        return;/*from   ww w.ja va  2 s.  c  o  m*/
    }
    //usually operator intentionally breaks call after 30minutes
    final long duration = time_end - time_start;
    final String readable_duration = String.format("%1$02dm:%2$02ds", TimeUnit.MILLISECONDS.toMinutes(duration),
            TimeUnit.MILLISECONDS.toSeconds(duration)
                    - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration)));
    final String filename = file.getName();
    final String path = file.getAbsolutePath();

    final DateFormat sdf = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
    final String readable_time = sdf.format(new Date(time_start));

    Intent intent = new Intent(this, SqlService.class);
    intent.putExtra(Const.COMMAND, Const.SqlService.SAVE);
    intent.putExtra(Const.MODEL, new RecordModel(time_start, time_end, readable_duration, filename, path,
            readable_time, phone, was_incoming));
    startService(intent);

}

From source file:net.dataforte.cohesive.CSVExporter.java

public void writeFile(OutputStream os) throws IOException {
    DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, new Locale("it"));
    PrintWriter pw = new PrintWriter(os);
    if (header) {
        boolean sep = false;
        for (CSVColumn column : columns) {
            if (sep) {
                pw.print(delimiter);/*  www.ja  v a  2 s. c o  m*/
            } else {
                sep = true;
            }
            if (useQuotes) {
                pw.print(quote);
            }
            pw.print(column.title);
            if (useQuotes) {
                pw.print(quote);
            }
        }
        pw.println();
    }
    for (Object row : data) {
        boolean sep = false;
        for (CSVColumn column : columns) {
            try {
                Object item = PropertyUtils.getProperty(row, column.property);
                if (sep) {
                    pw.print(delimiter);
                } else {
                    sep = true;
                }
                if (useQuotes) {
                    pw.print(quote);
                }
                if ((column.startIndex != null) && (column.endIndex != null)) {
                    item = ((String) item).substring(column.startIndex, column.endIndex);
                } else if (column.startIndex != null) {
                    item = ((String) item).substring(column.startIndex);
                } else if (column.endIndex != null) {
                    item = ((String) item).substring(0, column.endIndex);
                }
                if (column.format != null) {
                    pw.print(column.format.format(new Object[] { item }));
                } else if (item instanceof java.util.Date) {

                    pw.print(df.format((Date) item));
                } else {
                    pw.print(item.toString());
                }
                if (useQuotes) {
                    pw.print(quote);
                }
            } catch (Throwable t) {
                log.error("", t);
            }
        }
        pw.println();
    }
    pw.close();
}