Example usage for java.text DateFormat SHORT

List of usage examples for java.text DateFormat SHORT

Introduction

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

Prototype

int SHORT

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

Click Source Link

Document

Constant for short style pattern.

Usage

From source file:op.care.prescription.PnlScheduleDose.java

private void initPanel() {

    tabWdh.setTitleAt(0, SYSTools.xx("misc.msg.daily"));
    tabWdh.setTitleAt(1, SYSTools.xx("misc.msg.weekly"));
    tabWdh.setTitleAt(2, SYSTools.xx("misc.msg.monthly"));

    lblLDate.setText(SYSTools.xx(internalClassID + ".lblLDate") + " ");
    lblOnThe.setText(SYSTools.xx(internalClassID + ".lblOnThe"));
    lblMonth.setText(SYSTools.xx("misc.msg.months"));
    lblEach.setText(SYSTools.xx("misc.msg.every"));
    lblEvery1.setText(SYSTools.xx("misc.msg.every"));
    lblEvery2.setText(SYSTools.xx("misc.msg.every"));
    lblWeeksAt.setText(SYSTools.xx("misc.msg.weeks") + " " + SYSTools.xx("misc.msg.atchrono"));
    lblDays.setText(SYSTools.xx("misc.msg.Days2"));

    ArrayList<Date> timelist = SYSCalendar.getTimeList();
    cmbUhrzeit.setModel(new DefaultComboBoxModel(timelist.toArray()));
    cmbUhrzeit.setRenderer(SYSCalendar.getTimeRenderer());

    String[] wdaymodel = new String[] { SYSTools.xx("misc.msg.dayOfMonth"), SYSTools.xx("misc.msg.monday"),
            SYSTools.xx("misc.msg.tuesday"), SYSTools.xx("misc.msg.wednesday"),
            SYSTools.xx("misc.msg.thursday"), SYSTools.xx("misc.msg.friday"), SYSTools.xx("misc.msg.saturday"),
            SYSTools.xx("misc.msg.sunday") };
    cmbWDay.setModel(new DefaultComboBoxModel(wdaymodel));

    lblMon.setText(SYSTools.xx("misc.msg.monday"));
    lblTue.setText(SYSTools.xx("misc.msg.tuesday"));
    lblWed.setText(SYSTools.xx("misc.msg.wednesday"));
    lblThu.setText(SYSTools.xx("misc.msg.thursday"));
    lblFri.setText(SYSTools.xx("misc.msg.friday"));
    lblSat.setText(SYSTools.xx("misc.msg.saturday"));
    lblSun.setText(SYSTools.xx("misc.msg.sunday"));

    lblVeryEarly.setText(SYSTools.xx("misc.msg.earlyinthemorning.long"));
    lblMorning.setText(SYSTools.xx("misc.msg.morning.long"));
    lblNoon.setText(SYSTools.xx("misc.msg.noon.long"));
    lblAfternoon.setText(SYSTools.xx("misc.msg.afternoon.long"));
    lblEvening.setText(SYSTools.xx("misc.msg.evening.long"));
    lblVeryLate.setText(SYSTools.xx("misc.msg.lateatnight.long"));

    txtEveryDay.setText("1");
    txtEveryWeek.setText("1");
    txtEveryMonth.setText("1");
    txtEveryWDayOfMonth.setText("1");

    //        txtEveryDay.setText(schedule.getTaeglich().toString());
    //        txtEveryWeek.setText(schedule.getWoechentlich().toString());
    //        txtEveryMonth.setText(schedule.getMonatlich().toString());
    //        txtEveryWDayOfMonth.setText(schedule.getTagNum().toString());

    tabWdh.setSelectedIndex(TAB_DAILY);/*from www  .j  a  va 2  s .  c o m*/

    if (schedule.getWoechentlich() > 0) {
        cbMon.setSelected(schedule.getMon() > 0);
        cbTue.setSelected(schedule.getTue() > 0);
        cbWed.setSelected(schedule.getWed() > 0);
        cbThu.setSelected(schedule.getThu() > 0);
        cbFri.setSelected(schedule.getFri() > 0);
        cbSat.setSelected(schedule.getSat() > 0);
        cbSun.setSelected(schedule.getSun() > 0);
        tabWdh.setSelectedIndex(TAB_WEEKLY);
    }

    if (schedule.getMonatlich() > 0) {
        if (schedule.getTagNum() > 0) {
            txtEveryWDayOfMonth.setText(Short.toString(schedule.getTagNum()));
            cmbWDay.setSelectedIndex(0);
        } else {
            if (schedule.getMon() > 0) {
                cmbWDay.setSelectedIndex(1);
                txtEveryWDayOfMonth.setText(Short.toString(schedule.getMon()));
            } else if (schedule.getTue() > 0) {
                cmbWDay.setSelectedIndex(2);
                txtEveryWDayOfMonth.setText(Short.toString(schedule.getTue()));
            } else if (schedule.getWed() > 0) {
                cmbWDay.setSelectedIndex(3);
                txtEveryWDayOfMonth.setText(Short.toString(schedule.getWed()));
            } else if (schedule.getThu() > 0) {
                cmbWDay.setSelectedIndex(4);
                txtEveryWDayOfMonth.setText(Short.toString(schedule.getThu()));
            } else if (schedule.getFri() > 0) {
                cmbWDay.setSelectedIndex(5);
                txtEveryWDayOfMonth.setText(Short.toString(schedule.getFri()));
            } else if (schedule.getSat() > 0) {
                cmbWDay.setSelectedIndex(6);
                txtEveryWDayOfMonth.setText(Short.toString(schedule.getSat()));
            } else if (schedule.getSun() > 0) {
                cmbWDay.setSelectedIndex(7);
                txtEveryWDayOfMonth.setText(Short.toString(schedule.getSun()));
            }
        }
        tabWdh.setSelectedIndex(TAB_MONTHLY);
    }

    //        jdcLDatum.setMinSelectableDate(new Date());
    //        jdcLDatum.setDate(new Date(Math.max(schedule.getLDatum().getTime(), SYSCalendar.startOfDay())));

    DateMidnight scheduleLDate = new DateMidnight(schedule.getLDatum());
    DateMidnight today = new DateMidnight();
    DateMidnight ldate = new DateMidnight(Math.max(scheduleLDate.getMillis(), today.getMillis()));
    txtLDate.setText(DateFormat.getDateInstance().format(ldate.toDate()));

    txtVeryEarly.setText(schedule.getNachtMo().setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
    txtMorning.setText(schedule.getMorgens().setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
    txtNoon.setText(schedule.getMittags().setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
    txtAfternoon.setText(schedule.getNachmittags().setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
    txtEvening.setText(schedule.getAbends().setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
    txtVeryLate.setText(schedule.getNachtAb().setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
    txtTimeDose.setText(schedule.getUhrzeitDosis().setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());

    txtMorning.setBackground(SYSConst.lightblue);
    txtNoon.setBackground(SYSConst.gold7);
    txtAfternoon.setBackground(SYSConst.melonrindgreen);
    txtEvening.setBackground(SYSConst.bermuda_sand);
    txtVeryLate.setBackground(SYSConst.bluegrey);

    Date now = null;
    if (schedule.getUhrzeitDosis().compareTo(BigDecimal.ZERO) > 0) {
        splitRegularPos = 0.0d;
        now = schedule.getUhrzeit();
    } else {
        now = new Date();
        splitRegularPos = 1.0d;
    }

    for (Date zeit : timelist) {
        if (SYSCalendar.compareTime(zeit, now) >= 0) {
            now = zeit;
            break;
        }
    }
    cmbUhrzeit.setSelectedItem(now);
    lblTimeDose.setText(SYSTools.xx(internalClassID + ".lblTimeDose") + " "
            + DateFormat.getTimeInstance(DateFormat.SHORT).format(now) + " "
            + SYSTools.xx("misc.msg.Time.short"));

    panelMainComponentResized(null);
}

From source file:com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.java

private DateFormat[] getDateFormats(Locale locale) {
    DateFormat dt1 = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG, locale);
    DateFormat dt2 = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale);
    DateFormat dt3 = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale);

    DateFormat d1 = DateFormat.getDateInstance(DateFormat.SHORT, locale);
    DateFormat d2 = DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
    DateFormat d3 = DateFormat.getDateInstance(DateFormat.LONG, locale);

    DateFormat rfc3399 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");

    DateFormat[] dfs = { dt1, dt2, dt3, rfc3399, d1, d2, d3 }; //added RFC 3339 date format (XW-473)
    return dfs;/*from   www. j  av a  2s. c o  m*/
}

From source file:org.apache.hadoop.filecache.TrackerDistributedCacheManager.java

/**
 * Download a given path to the local file system.
 * @param conf the job's configuration//from  w  ww  . j  a va  2 s . c om
 * @param source the source to copy from
 * @param destination where to copy the file. must be local fs
 * @param desiredTimestamp the required modification timestamp of the source
 * @param isArchive is this an archive that should be expanded
 * @param permission the desired permissions of the file.
 * @return for archives, the number of bytes in the unpacked directory
 * @throws IOException
 */
public static long downloadCacheObject(Configuration conf, URI source, Path destination, long desiredTimestamp,
        boolean isArchive, FsPermission permission) throws IOException {
    FileSystem sourceFs = FileSystem.get(source, conf);
    FileSystem localFs = FileSystem.getLocal(conf);

    Path sourcePath = new Path(source.getPath());
    long modifiedTime = sourceFs.getFileStatus(sourcePath).getModificationTime();
    if (modifiedTime != desiredTimestamp) {
        DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
        throw new IOException("The distributed cache object " + source + " changed during the job from "
                + df.format(new Date(desiredTimestamp)) + " to " + df.format(new Date(modifiedTime)));
    }

    Path parchive = null;
    if (isArchive) {
        parchive = new Path(destination, destination.getName());
    } else {
        parchive = destination;
    }
    // if the file already exists, we are done
    if (localFs.exists(parchive)) {
        return 0;
    }
    // the final directory for the object
    Path finalDir = parchive.getParent();
    // the work directory for the object
    Path workDir = createRandomPath(finalDir);
    LOG.info("Creating " + destination.getName() + " in " + workDir + " with " + permission);
    if (!localFs.mkdirs(workDir, permission)) {
        throw new IOException("Mkdirs failed to create directory " + workDir);
    }
    Path workFile = new Path(workDir, parchive.getName());
    sourceFs.copyToLocalFile(sourcePath, workFile);
    localFs.setPermission(workFile, permission);
    if (isArchive) {
        String tmpArchive = workFile.getName().toLowerCase();
        File srcFile = new File(workFile.toString());
        File destDir = new File(workDir.toString());
        LOG.info(String.format("Extracting %s to %s", srcFile.toString(), destDir.toString()));
        if (tmpArchive.endsWith(".jar")) {
            RunJar.unJar(srcFile, destDir);
        } else if (tmpArchive.endsWith(".zip")) {
            FileUtil.unZip(srcFile, destDir);
        } else if (isTarFile(tmpArchive)) {
            FileUtil.unTar(srcFile, destDir);
        } else {
            LOG.warn(String.format("Cache file %s specified as archive, but not valid extension.",
                    srcFile.toString()));
            // else will not do anyhting
            // and copy the file into the dir as it is
        }
        FileUtil.chmod(destDir.toString(), "ugo+rx", true);
    }
    // promote the output to the final location
    if (!localFs.rename(workDir, finalDir)) {
        localFs.delete(workDir, true);
        if (!localFs.exists(finalDir)) {
            throw new IOException("Failed to promote distributed cache object " + workDir + " to " + finalDir);
        }
        // someone else promoted first
        return 0;
    }

    LOG.info(String.format("Cached %s as %s", source.toString(), destination.toString()));
    long cacheSize = FileUtil.getDU(new File(parchive.getParent().toString()));
    return cacheSize;
}

From source file:com.cachirulop.moneybox.activity.MovementDetailActivity.java

/**
 * Update the get time field of the window with the value of the movement
 * object./* w  w w.  j a  v  a2  s  .  c  o  m*/
 */
private void updateGetTime() {
    TextView txt;

    txt = (TextView) findViewById(R.id.txtGetTime);
    if (_movement.getGetDate() != null) {
        txt.setText(DateFormat.getTimeInstance(DateFormat.SHORT).format(_movement.getGetDate()));
    } else {
        txt.setText("");
    }
}

From source file:net.clcworld.thermometer.TakeTemperatureReadingActivity.java

public void sendData(final String patientId, final String temperature, final String feeling,
        final ArrayList<String> symptoms) {
    final String targetUrl = mPrefs.getString("targetUrl", "");
    final String idField = mPrefs.getString("idField", "");
    final String tempField = mPrefs.getString("tempField", "");
    final String feelingField = mPrefs.getString("feelingField", "");
    final String symptomsField = mPrefs.getString("symptomsField", "");
    if (targetUrl.length() > 0) {
        UploadUtils.sendData(targetUrl, idField, tempField, feelingField, symptomsField, patientId, temperature,
                feeling, symptoms);//  w  ww. j  a va 2s.c o  m
        Toast.makeText(mSelf, R.string.submitted, Toast.LENGTH_SHORT).show();
    } else {
        Toast.makeText(mSelf, R.string.saved, Toast.LENGTH_SHORT).show();
    }

    String entry = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date())
            + "    " + temperature + "F    " + feeling + "\n";
    Editor editor = mPrefs.edit();
    editor.putString(PREFSKEY_HISTORY, entry + mHistory);
    editor.commit();

    finish();
}

From source file:com.redhat.rhn.common.localization.LocalizationService.java

/**
 * Format the date as a short date depending on locale (YYYY-MM-DD in the
 * US)//from   w w w .  j  ava 2s .  c o m
 *
 * @param date Date to be formatted
 * @param locale Locale to use for formatting
 * @return String representation of given date.
 */
public String formatShortDate(Date date, Locale locale) {

    StringBuilder dbuff = new StringBuilder();
    DateFormat dateI = DateFormat.getDateInstance(DateFormat.SHORT, locale);

    dbuff.append(dateI.format(date));

    return getDebugVersionOfString(dbuff.toString());
}

From source file:fr.paris.lutece.plugins.form.utils.FormUtils.java

/**
 * Converts une java.sql.Timestamp date in a String date in a "jj/mm/aaaa" format
 *
 * @param date java.sql.Timestamp date to convert
 * @param locale the locale// ww w.  j  a  v a 2 s.c o  m
 * @return strDate The String date in the short locale format or the emmpty String if the date is null
 * @deprecated
 */
public static String getDateString(Timestamp date, Locale locale) {
    DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, locale);

    return dateFormat.format(date);
}

From source file:com.cachirulop.moneybox.activity.MovementDetailActivity.java

/**
 * Update the insert time field of the window with the value of the movement
 * object.// w w  w .  j  av  a 2 s.  co m
 */
private void updateInsertTime() {
    TextView txt;

    txt = (TextView) findViewById(R.id.txtTime);
    txt.setText(DateFormat.getTimeInstance(DateFormat.SHORT).format(_movement.getInsertDate()));
}

From source file:com.diablominer.DiabloMiner.DiabloMiner.java

public static String dateTime() {
    return "[" + DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date()) + "]";
}

From source file:com.examples.with.different.packagename.testcarver.DateTimeConverter.java

/**
 * Return a <code>DateFormat<code> for the Locale.
 * @param locale The Locale to create the Format with (may be null)
 * @param timeZone The Time Zone create the Format with (may be null)
 *
 * @return A Date Format./*from  w  w  w. j  a  v a2 s .  co m*/
 */
protected DateFormat getFormat(Locale locale, TimeZone timeZone) {
    DateFormat format = null;
    if (locale == null) {
        format = DateFormat.getDateInstance(DateFormat.SHORT);
    } else {
        format = DateFormat.getDateInstance(DateFormat.SHORT, locale);
    }
    if (timeZone != null) {
        format.setTimeZone(timeZone);
    }
    return format;
}