List of usage examples for org.joda.time.format DateTimeFormat longDate
public static DateTimeFormatter longDate()
From source file:cc.vidr.datum.builtin.TermFormat.java
License:Open Source License
private String format(DateTimeTerm datetime) { return datetime.toString(DateTimeFormat.longDate()); }
From source file:com.effektif.workflow.impl.data.types.DateTypeImpl.java
License:Apache License
@Override public String convertInternalToText(Object value, Hints hints) { DateTimeFormatter textFormatter = DateTimeFormat.longDate().withLocale(getLocale()); return value != null ? textFormatter.print((ReadablePartial) value) : null; }
From source file:com.helger.datetime.format.PDTFormatter.java
License:Apache License
/** * Get the long date formatter for the passed locale. * * @param aDisplayLocale/*from www .j a v a 2s. 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 getLongFormatterDate(@Nullable final Locale aDisplayLocale) { return getWithLocaleAndChrono(DateTimeFormat.longDate(), 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. *///from www. j a va 2 s. com 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);/* w w w . j a v a 2 s. co m*/ } }); 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.userweave.domain.util.xml.InvoiceCreator.java
License:Open Source License
/** * Create XML Representation of Invoice of given Study * @param study/* w ww. jav a 2 s .com*/ * @return */ public String toXML(Study study) { DecimalFormat df_us = (DecimalFormat) DecimalFormat.getInstance(Locale.US); df_us.applyPattern("#0.00"); DecimalFormat df_de = (DecimalFormat) DecimalFormat.getInstance(Locale.GERMAN); df_de.applyPattern("#0.00"); Document document = DocumentHelper.createDocument(); Element invoice = document.addElement("invoice"); Element receipient = invoice.addElement("receipient"); Element details = invoice.addElement("details"); if (study.getOwner().getCompany() != null) { receipient.addElement("company").addText(study.getOwner().getCompany()); } else { receipient.addElement("company").addText(""); } receipient.addElement("surname").addText(study.getOwner().getSurname()); receipient.addElement("forename").addText(study.getOwner().getForename()); Element address = receipient.addElement("address"); if (study.getOwner().getAddress() != null) { address.addElement("street").addText(study.getOwner().getAddress().getStreet()); address.addElement("housenumber").addText(study.getOwner().getAddress().getHouseNumber()); address.addElement("postcode").addText(study.getOwner().getAddress().getPostcode()); address.addElement("city").addText(study.getOwner().getAddress().getCity()); address.addElement("country").addText(study.getOwner().getAddress().getCountry().getName()); } details.addElement("number").addText(study.getConsideration().getInvoice().getNumber()); DateTime invoiceDate = study.getConsideration().getDate(); DateTimeFormatter dateDTF = DateTimeFormat.longDate(); DateTimeFormatter usFmt = dateDTF.withLocale(Locale.US); String dateString = invoiceDate.toString(usFmt); if (evaluateReceipient(study) == Receipient.GERMAN_ALL) { DateTimeFormatter deFmt = dateDTF.withLocale(Locale.GERMAN); dateString = invoiceDate.toString(deFmt); } details.addElement("date").addText(dateString); details.addElement("currency").addText(study.getConsideration().getCurrency().getCurrencyCode()); Double gross = study.getConsideration().getGrossAmount(); if (study.getConsideration().getGrossAmount() != null) { String grossString = df_us.format(study.getConsideration().getGrossAmount()); if (evaluateReceipient(study) == Receipient.GERMAN_ALL) { grossString = df_de.format(study.getConsideration().getGrossAmount()); } details.addElement("gross").addText(grossString); } else { details.addElement("gross").addText(new Integer(0).toString()); } if (study.getConsideration().getInvoice().getPurchaseTaxPercent() != null && study.getConsideration().getInvoice().getPurchaseTaxPercent() > 0d) { String netString = df_us.format(study.getConsideration().getInvoice().getNetAmount()); if (evaluateReceipient(study) == Receipient.GERMAN_ALL) { netString = df_de.format(study.getConsideration().getInvoice().getNetAmount()); } details.addElement("net").addText(netString); Double tax = new Double(study.getConsideration().getGrossAmount() - study.getConsideration().getInvoice().getNetAmount()); tax = Math.round(tax * 100.) / 100.; String taxString = df_us.format(tax); if (evaluateReceipient(study) == Receipient.GERMAN_ALL) { netString = df_de.format(tax); } details.addElement("tax").addText(taxString); String taxRateString = df_us.format(study.getConsideration().getInvoice().getPurchaseTaxPercent()); if (evaluateReceipient(study) == Receipient.GERMAN_ALL) { netString = df_de.format(study.getConsideration().getInvoice().getPurchaseTaxPercent()); } details.addElement("taxrate").addText(taxRateString); } else { details.addElement("net").addText(new Integer(0).toString()); details.addElement("tax").addText(new Integer(0).toString()); details.addElement("taxrate") .addText(study.getConsideration().getInvoice().getPurchaseTaxPercent().toString()); } return document.asXML(); }
From source file:com.userweave.pages.user.configuration.UserApiCredentialsPanel.java
License:Open Source License
public UserApiCredentialsPanel(String id, UserModel userModel) { super(id);//from www .j a va2s . c o m model = userModel; AddModalWindows(); final FeedbackPanel feedbackPanel = new FeedbackPanel("feedbackPanel"); feedbackPanel.setOutputMarkupId(true); add(feedbackPanel); createApiCredentialsContainer = new WebMarkupContainer("createApiCredentialsContainer") { @Override public boolean isVisible() { return !hasUserApiCredentials(); } }; createApiCredentialsContainer.setOutputMarkupPlaceholderTag(true); add(createApiCredentialsContainer); apiCredentialsContainer = new WebMarkupContainer("apiCredentialsContainer") { @Override public boolean isVisible() { return hasUserApiCredentials(); } }; apiCredentialsContainer.setOutputMarkupPlaceholderTag(true); add(apiCredentialsContainer); Form form = new Form("form"); createApiCredentialsContainer.add(form); form.add(new DefaultButton("createButton", new ResourceModel("createApiCredentials"), form) { @Override protected void onError(AjaxRequestTarget target, Form form) { target.addComponent(feedbackPanel); } @Override protected void onSubmit(AjaxRequestTarget target, Form form) { target.addComponent(feedbackPanel); // create new apiCredential ApiCredentials apiCred = new ApiCredentials(); apiCred.setHash(HashProvider.uniqueUUID()); apiCred.setActiveLastChange(new DateTime()); apiCredentialsDao.save(apiCred); User user = model.getObject(); user.setApiCredentials(apiCred); userDao.save(user); apiCredentialsContainer.setVisible(true); createApiCredentialsContainer.setVisible(false); target.addComponent(apiCredentialsContainer); target.addComponent(createApiCredentialsContainer); }; }); apiCredentialsContainer.add(new Label("apiAuthHash", new PropertyModel(model, "apiCredentials.hash"))); apiCredentialsContainer.add(new AjaxLink("genHash") { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(feedbackPanel); generateHashModalWindow.show(target); } @Override public boolean isVisible() { return UserWeaveSession.get().isAdmin(); } }); WebMarkupContainer activeAdminContainer = new WebMarkupContainer("activeAdminContainer") { @Override public boolean isVisible() { return UserWeaveSession.get().isAdmin(); } }; apiCredentialsContainer.add(activeAdminContainer); final AjaxCheckBox activeChkBx = new AjaxCheckBox("active", new PropertyModel(model, "apiCredentials.active")) { @Override protected void onUpdate(AjaxRequestTarget target) { target.addComponent(feedbackPanel); userDao.save(model.getObject()); } }; activeChkBx.setOutputMarkupId(true); activeAdminContainer.add(activeChkBx); WebMarkupContainer activeContainer = new WebMarkupContainer("activeContainer") { @Override public boolean isVisible() { return !UserWeaveSession.get().isAdmin(); } }; apiCredentialsContainer.add(activeContainer); String dateString = new StringResourceModel("noActiveDate", this, null).getString(); if (model.getObject().getApiCredentials() != null && model.getObject().getApiCredentials().getActiveLastChange() != null) { DateTimeFormatter dateDTF = DateTimeFormat.longDate(); DateTimeFormatter usFmt = dateDTF.withLocale(UserWeaveSession.get().getLocale()); dateString = model.getObject().getApiCredentials().getActiveLastChange().toString(usFmt); } Label activeLabel = new Label("activeText", new StringResourceModel("deactiveFormat", this, null, new Object[] { dateString })); if (model.getObject().getApiCredentials() != null && model.getObject().getApiCredentials().isActive()) { activeLabel.setDefaultModel( new StringResourceModel("activeFormat", this, null, new Object[] { dateString })); } activeContainer.add(activeLabel); WebMarkupContainer deleteContainer = new WebMarkupContainer("deleteContainer") { @Override public boolean isVisible() { return UserWeaveSession.get().isAdmin(); } }; apiCredentialsContainer.add(deleteContainer); deleteContainer.add(new AjaxLink("delete") { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(feedbackPanel); deleteModalWindow.show(target); } }); }
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:/*w w w . j a v a2 s.c o 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:gg.db.datamodel.Period.java
License:Open Source License
/** * Returns a string description of the period * @return Description of the period <BR/> * <B>Example: </B>/*from w ww. j ava 2 s . co m*/ * <UL> * <LI><B>DAY</B>: "11/20/2005" (Depending on the format of the date defined in Configuration.dateFormat)</LI> * <LI><B>WEEK</B>: "43 (2005)"</LI> * <LI><B>MONTH</B>: "Jully 2005"</LI> * <LI><B>YEAR</B>: "2005"</LI> * <LI><B>FREE</B>: "From 11/20/2005 to 11/27/2005"</LI> * </UL> */ @Override public String toString() { assert (start != null && end != null && periodType != null); String strFrom = NbBundle.getMessage(Period.class, "Period.From"); String strTo = NbBundle.getMessage(Period.class, "Period.To"); // Creates the string description depending on the type of the period String description = ""; // The string description of the period switch (periodType) { case DAY: // April 14, 2006 (depending on what is defined in Configuration.dateFormat) description = DateTimeFormat.longDate().print(start.toDateMidnight()); break; case WEEK: // 43 (2005) description = start.toDateTimeAtCurrentTime().getWeekOfWeekyear() + " (" + start.getYear() + ")"; break; case MONTH: // Jully 2005 description = start.monthOfYear().getAsShortText() + " " + start.getYear(); break; case YEAR: // 2001 description = String.valueOf(start.getYear()); break; case FREE: // From 20/11/2005 to 27/11/2005 (Depending on what is defined in Configuration) description = strFrom + " " + DateTimeFormat.longDate().print(start.toDateMidnight()) + " " + strTo + " " + DateTimeFormat.longDate().print(end.toDateMidnight()); break; default: // Should never happen throw new AssertionError("The PeriodType is unkwown"); } return description; }
From source file:net.sourceforge.atunes.gui.views.dialogs.RecommendedEventsDialog.java
License:Open Source License
private void showEventDetails(IEvent event) { this.eventImage.loadImage(event.getOriginalImageUrl()); this.eventTitle.setText(event.getTitle()); this.eventDate.setText(DateTimeFormat.longDate().print(event.getStartDate())); this.eventVenue.setText(event.getVenue()); this.eventCity.setText(event.getCity()); this.eventCountry.setText(event.getCountry()); StringBuilder artists = new StringBuilder(); artists.append("<html>"); for (String artist : event.getArtists()) { artists.append(artist);//www . j a v a 2 s. c o m artists.append("<br>"); } artists.append("</html>"); this.eventArtists.setText(artists.toString()); this.readMore.setText(I18nUtils.getString("READ_MORE"), event.getUrl()); }