Example usage for org.joda.time.format DateTimeFormat mediumDate

List of usage examples for org.joda.time.format DateTimeFormat mediumDate

Introduction

In this page you can find the example usage for org.joda.time.format DateTimeFormat mediumDate.

Prototype

public static DateTimeFormatter mediumDate() 

Source Link

Document

Creates a format that outputs a medium date format.

Usage

From source file:com.anrisoftware.prefdialog.appdialogs.registerdialog.RegisterDialog.java

License:Open Source License

private void updateTexts() {
    this.dateFormatter = DateTimeFormat.mediumDate().withLocale(getLocale());
    updateRegisterText();//from  ww w .j a v a2s.c  o  m
    updateEmailText();
    updateKeyText();
    updateCodeText();
    updateNameText();
}

From source file:com.helger.datetime.format.PDTFormatter.java

License:Apache License

/**
 * Get the medium date formatter for the passed locale.
 *
 * @param aDisplayLocale//from  ww w. j a v  a 2 s.com
 *        The display locale to be used. May be <code>null</code>.
 * @return The created date time formatter. Never <code>null</code>.
 */
@Nonnull
public static DateTimeFormatter getMediumFormatterDate(@Nullable final Locale aDisplayLocale) {
    return getWithLocaleAndChrono(DateTimeFormat.mediumDate(), aDisplayLocale);
}

From source file:com.hmsinc.epicenter.velocity.DateTimeFormatTool.java

License:Open Source License

/**
 * Checks a string to see if it matches one of the standard DateTimeFormat
 * style patterns: full, long, medium, short, or default.
 *//*w w  w .  java2  s  .  c o m*/
private static DateTimeFormatter getDateStyle(String style, Locale locale, DateTimeZone zone) {
    final DateTimeFormatter ret;

    if (style.equalsIgnoreCase("full")) {
        ret = DateTimeFormat.fullDate();
    } else if (style.equalsIgnoreCase("long")) {
        ret = DateTimeFormat.longDate();
    } else if (style.equalsIgnoreCase("medium")) {
        ret = DateTimeFormat.mediumDate();
    } else if (style.equalsIgnoreCase("short")) {
        ret = DateTimeFormat.shortDate();
    } else if (style.equalsIgnoreCase("none")) {
        ret = null;
    } else {
        ret = DateTimeFormat.forPattern(style);
    }

    return ret == null ? null : ret.withLocale(locale).withZone(zone);
}

From source file:com.moss.joda.swing.LiveDatePicker.java

License:Open Source License

public LiveDatePicker() {
    formats.add(DateTimeFormat.shortDate());
    formats.add(ISODateTimeFormat.date());
    formats.add(ISODateTimeFormat.basicDate());
    formats.add(DateTimeFormat.mediumDate());
    formats.add(DateTimeFormat.fullDate());
    formats.add(DateTimeFormat.longDate());

    //      p = new JXDatePicker();
    //      pButton = p.getComponent(1);
    //      p.getEditor().setVisible(false);

    pButton = new JButton("^");
    pButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Point p = pButton.getLocation();
            popup.show(pButton, 0, 0);/*from   ww  w .  ja va 2 s .c  om*/

        }
    });
    popup.add(new DateSelectionListener() {
        public void dateSelected(YearMonthDay date) {
            setDate(date);
            fireSelection();
        }
    });

    t.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            handle();
        }

        public void insertUpdate(DocumentEvent e) {
            handle();
        }

        public void removeUpdate(DocumentEvent e) {
            handle();
        }

        void handle() {
            if (!uiUpdating) {
                String text = t.getText();
                YearMonthDay date = null;
                for (int x = 0; date == null && x < formats.size(); x++) {
                    DateTimeFormatter f = formats.get(x);
                    try {
                        date = f.parseDateTime(text).toYearMonthDay();
                    } catch (IllegalArgumentException e) {
                    }
                }
                value = date;
                if (date != null) {
                    popup.setDate(date);
                }
                fireSelection();
            }
        }

    });

    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.ipadx = 10;
    add(t, c);
    c.weightx = 0;
    c.ipadx = 0;
    //      c.insets.left = 5;
    add(pButton, c);

    setDate(new YearMonthDay());
}

From source file:com.ning.billing.invoice.template.formatters.DefaultInvoiceFormatter.java

License:Apache License

public DefaultInvoiceFormatter(final TranslatorConfig config, final Invoice invoice, final Locale locale) {
    this.config = config;
    this.invoice = invoice;
    dateFormatter = DateTimeFormat.mediumDate().withLocale(locale);
    this.locale = locale;
}

From source file:com.robwilliamson.healthyesther.fragment.edit.EditEventFragment.java

License:Open Source License

private void updateUi() {
    mSettingRowName = true;/*www .  j  ava  2s. c o m*/
    if (hasRow()) {
        @SuppressWarnings("ConstantConditions")
        @Nonnull
        EventTable.Row row = getRow();
        if (getNameView() != null) {
            String rowName = row.getName();
            Editable editable = getNameView().getEditableText();

            editable.clear();
            if (rowName != null) {
                editable.append(rowName);
            }
        }

        if (getTimeButton() != null) {
            getTimeButton()
                    .setText(Utils.Time.toString(row.getWhen().as(DateTime.class), DateTimeFormat.shortTime()));
        }

        if (getDateButton() != null) {
            getDateButton().setText(
                    Utils.Time.toString(row.getWhen().as(DateTime.class), DateTimeFormat.mediumDate()));
        }
    }
    mSettingRowName = false;
}

From source file:com.vityuk.ginger.provider.format.JodaTimeUtils.java

License:Apache License

private static DateTimeFormatter createJodaDateFormatter(FormatType formatType, DateFormatStyle formatStyle) {
    switch (formatType) {
    case TIME://from w w w . j ava  2  s . co m
        switch (formatStyle) {
        case SHORT:
            return DateTimeFormat.shortTime();
        case MEDIUM:
            return DateTimeFormat.mediumTime();
        case LONG:
            return DateTimeFormat.longTime();
        case FULL:
            return DateTimeFormat.fullTime();
        case DEFAULT:
            return ISODateTimeFormat.time();
        }
    case DATE:
        switch (formatStyle) {
        case SHORT:
            return DateTimeFormat.shortDate();
        case MEDIUM:
            return DateTimeFormat.mediumDate();
        case LONG:
            return DateTimeFormat.longDate();
        case FULL:
            return DateTimeFormat.fullDate();
        case DEFAULT:
            return ISODateTimeFormat.date();
        }
    case DATETIME:
        switch (formatStyle) {
        case SHORT:
            return DateTimeFormat.shortDateTime();
        case MEDIUM:
            return DateTimeFormat.mediumDateTime();
        case LONG:
            return DateTimeFormat.longDateTime();
        case FULL:
            return DateTimeFormat.fullDateTime();
        case DEFAULT:
            return ISODateTimeFormat.dateTime();
        }
    }

    throw new IllegalArgumentException();
}

From source file:damo.three.ie.util.DateUtils.java

License:Open Source License

/**
 * Convert a date as milliseconds to a string representation
 *
 * @param input Date in milliseconds/*from ww  w.j  a  v a 2  s . c o m*/
 * @return {@link String}
 */
public static String formatDate(Number input) {
    if (input == null || input.longValue() == WONT_EXPIRE) {
        return "Won't expire";
    } else if (input.longValue() == QUEUED) {
        return "Queued";
    }

    DateTime dateTime = new DateTime(input.longValue());
    DateTimeFormatter dateTimeFormatter = DateTimeFormat.mediumDate();

    return dateTimeFormatter.print(dateTime);
}

From source file:de.atomfrede.android.thwdroid.damageaccount.activity.DisplayDamageAccountDetailsActivity.java

License:Apache License

public void refresh() {
    damageAccount = (DamageAccount) getModel(damageAccountId);

    if (damageAccount.getDamageList() != null)
        listAdapter = new DamageListAdapter(this, damageAccount.getDamageList(), false);
    else//from w w  w. j  av a  2s .  c  om
        listAdapter = new DamageListAdapter(this, new ArrayList<Damage>(), false);

    TextView damageAccountnameTextView = (TextView) findViewById(R.id.damage_account_title);
    TextView damageAccountTimeTextView = (TextView) findViewById(R.id.time_text_view);

    damageAccountnameTextView.setText(damageAccount.getName());
    if (damageAccount.getTime() != null)
        damageAccountTimeTextView.setText(damageAccount.getTime().toString(DateTimeFormat.mediumDate()));
    else
        damageAccountTimeTextView.setText("Not available");

    setListAdapter(listAdapter);
}

From source file:de.atomfrede.android.thwdroid.damageaccount.activity.EditDamageAccountActivity.java

License:Apache License

public void refresh() {
    damageAccount = (DamageAccount) getModel(damageAccountId);

    if (damageAccount.getDamageList() != null)
        listAdapter = new DamageListAdapter(this, damageAccount.getDamageList(), true);
    else//from   ww  w.  j  av  a2s  .c o  m
        listAdapter = new DamageListAdapter(this, new ArrayList<Damage>(), false);

    EditText damageAccountnameTextView = (EditText) findViewById(R.id.damage_account_title);
    TextView damageAccountTimeTextView = (TextView) findViewById(R.id.time_text_view);

    damageAccountnameTextView.setText(damageAccount.getName());
    if (damageAccount.getTime() != null)
        damageAccountTimeTextView.setText(damageAccount.getTime().toString(DateTimeFormat.mediumDate()));
    else
        damageAccountTimeTextView.setText("Not available");

    setListAdapter(listAdapter);
}