List of usage examples for java.text DateFormat FULL
int FULL
To view the source code for java.text DateFormat FULL.
Click Source Link
From source file:de.uniwue.info6.webapp.lists.ExGroupTableBean.java
/** * * * @param ex//w ww .j av a 2 s . c o m * @return */ public String getLastUserEntryTime(Exercise ex) { UserEntry entry = userEntryDao.getLastUserEntry(ex); if (entry != null) { DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.FULL, new Locale("de", "DE")); return df.format(entry.getEntryTime()); } return null; }
From source file:fr.hoteia.qalingo.core.service.impl.EmailServiceImpl.java
/** * @see fr.hoteia.qalingo.core.service.EmailService#buildAndSaveCustomerNewAccountMail(Localization localization, Customer customer, String velocityPath, CustomerNewAccountConfirmationEmailBean customerNewAccountConfirmationEmailBean) *///from ww w . j a v a 2 s .c o m public void buildAndSaveCustomerNewAccountMail(final RequestData requestData, final String velocityPath, final CustomerNewAccountConfirmationEmailBean customerNewAccountConfirmationEmailBean) throws Exception { try { final Localization localization = requestData.getLocalization(); final Locale locale = localization.getLocale(); // SANITY CHECK checkEmailAddresses(customerNewAccountConfirmationEmailBean); Map<String, Object> model = new HashMap<String, Object>(); DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.FULL, locale); java.sql.Timestamp currentDate = new java.sql.Timestamp((new java.util.Date()).getTime()); model.put("currentDate", dateFormatter.format(currentDate)); model.put("customerNewAccountConfirmationEmailBean", customerNewAccountConfirmationEmailBean); model.put("wording", coreMessageSource.loadWording(Email.WORDING_SCOPE_EMAIL, locale)); String fromEmail = customerNewAccountConfirmationEmailBean.getFromEmail(); MimeMessagePreparatorImpl mimeMessagePreparator = getMimeMessagePreparator(requestData, Email.EMAIl_TYPE_NEW_ACCOUNT_CONFIRMATION, model); mimeMessagePreparator.setTo(customerNewAccountConfirmationEmailBean.getToEmail()); mimeMessagePreparator.setFrom(fromEmail); mimeMessagePreparator.setFromName(coreMessageSource.getMessage("email.common.from_name", locale)); mimeMessagePreparator.setReplyTo(fromEmail); Object[] parameters = { customerNewAccountConfirmationEmailBean.getLastname(), customerNewAccountConfirmationEmailBean.getFirstname() }; mimeMessagePreparator.setSubject( coreMessageSource.getMessage("email.new_account.email_subject", parameters, locale)); mimeMessagePreparator.setHtmlContent(VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, velocityPath + "new-account-confirmation-html-content.vm", model)); mimeMessagePreparator.setPlainTextContent(VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, velocityPath + "new-account-confirmation-text-content.vm", model)); Email email = new Email(); email.setType(Email.EMAIl_TYPE_NEW_ACCOUNT_CONFIRMATION); email.setStatus(Email.EMAIl_STATUS_PENDING); saveOrUpdateEmail(email, mimeMessagePreparator); } catch (MailException e) { LOG.error("Error, can't save the message :", e); throw e; } catch (VelocityException e) { LOG.error("Error, can't build the message :", e); throw e; } catch (IOException e) { LOG.error("Error, can't serializable the message :", e); throw e; } }
From source file:fr.paris.lutece.plugins.genericalert.service.TaskNotifyReminder.java
/** * Get message text/*from ww w . ja va 2 s. c o m*/ * @param msg the text message * @param appointment the appointment * @return the text message */ private String getMessageAppointment(String msg, Appointment appointment) { DateFormat formater = DateFormat.getDateInstance(DateFormat.FULL, Locale.FRENCH); SimpleDateFormat formatTime = new SimpleDateFormat("HH:mm"); String strLocation = appointment.getLocation() == null ? StringUtils.EMPTY : appointment.getLocation(); String strText = StringUtils.EMPTY; strText = msg.replace(MARK_FIRST_NAME, appointment.getFirstName()); strText = strText.replace(MARK_LAST_NAME, appointment.getLastName()); strText = strText.replace(MARK_DATE_APP, formater.format(appointment.getDateAppointment())); strText = strText.replace(MARK_TIME_APP, formatTime.format(appointment.getStartAppointment())); strText = strText.replace(MARK_LOCALIZATION, strLocation); strText = strText.replace(MARK_CANCEL_APP, AppointmentApp.getCancelAppointmentUrl(appointment)); return strText; }
From source file:org.hoteia.qalingo.core.service.impl.EmailServiceImpl.java
/** * @see org.hoteia.qalingo.core.service.EmailService#buildAndSaveCustomerNewAccountMail(Localization localization, Customer customer, String velocityPath, CustomerNewAccountConfirmationEmailBean customerNewAccountConfirmationEmailBean) *//* ww w. j av a 2s. c o m*/ public void buildAndSaveCustomerNewAccountMail(final RequestData requestData, final String velocityPath, final CustomerNewAccountConfirmationEmailBean customerNewAccountConfirmationEmailBean) throws Exception { try { final Localization localization = requestData.getMarketAreaLocalization(); final Locale locale = localization.getLocale(); // SANITY CHECK checkEmailAddresses(customerNewAccountConfirmationEmailBean); Map<String, Object> model = new HashMap<String, Object>(); DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.FULL, locale); java.sql.Timestamp currentDate = new java.sql.Timestamp((new java.util.Date()).getTime()); model.put(CURRENT_DATE, dateFormatter.format(currentDate)); model.put("customerNewAccountConfirmationEmailBean", customerNewAccountConfirmationEmailBean); model.put(WORDING, coreMessageSource.loadWording(Email.WORDING_SCOPE_EMAIL, locale)); Map<String, String> urlParams = new HashMap<String, String>(); urlParams.put(RequestConstants.REQUEST_PARAMETER_NEW_CUSTOMER_VALIDATION_EMAIL, URLEncoder.encode(customerNewAccountConfirmationEmailBean.getEmail(), Constants.ANSI)); urlParams.put(RequestConstants.REQUEST_PARAMETER_NEW_CUSTOMER_VALIDATION_TOKEN, UUID.randomUUID().toString()); String resetPasswordUrl = urlService.generateUrl(FoUrls.CUSTOMER_NEW_ACCOUNT_VALIDATION, requestData, urlParams); model.put("newCustomerValidationUrl", urlService.buildAbsoluteUrl(requestData, resetPasswordUrl)); String fromAddress = handleFromAddress(customerNewAccountConfirmationEmailBean.getFromAddress(), locale); String fromName = handleFromName(customerNewAccountConfirmationEmailBean.getFromName(), locale); String toEmail = customerNewAccountConfirmationEmailBean.getToEmail(); MimeMessagePreparatorImpl mimeMessagePreparator = getMimeMessagePreparator(requestData, Email.EMAIl_TYPE_NEW_ACCOUNT_CONFIRMATION, model); mimeMessagePreparator.setTo(toEmail); mimeMessagePreparator.setFrom(fromAddress); mimeMessagePreparator.setFromName(fromName); mimeMessagePreparator.setReplyTo(fromAddress); Object[] parameters = { customerNewAccountConfirmationEmailBean.getLastname(), customerNewAccountConfirmationEmailBean.getFirstname() }; mimeMessagePreparator.setSubject( coreMessageSource.getMessage("email.new_account.email_subject", parameters, locale)); mimeMessagePreparator.setHtmlContent(VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, velocityPath + "new-account-confirmation-html-content.vm", model)); mimeMessagePreparator.setPlainTextContent(VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, velocityPath + "new-account-confirmation-text-content.vm", model)); Email email = new Email(); email.setType(Email.EMAIl_TYPE_NEW_ACCOUNT_CONFIRMATION); email.setStatus(Email.EMAIl_STATUS_PENDING); saveOrUpdateEmail(email, mimeMessagePreparator); } catch (MailException e) { logger.error("Error, can't save the message :", e); throw e; } catch (VelocityException e) { logger.error("Error, can't build the message :", e); throw e; } catch (IOException e) { logger.error("Error, can't serializable the message :", e); throw e; } }
From source file:org.freeplane.features.format.FormatController.java
private static Integer getDateStyle(final String string) { if (string.equals("SHORT")) return DateFormat.SHORT; if (string.equals("MEDIUM")) return DateFormat.MEDIUM; if (string.equals("LONG")) return DateFormat.LONG; if (string.equals("FULL")) return DateFormat.FULL; return null;/*from www. j a v a 2s . c om*/ }
From source file:org.hoteia.qalingo.core.service.EmailService.java
/** * @throws Exception //from w ww .ja v a2s . c o m */ public Email buildAndSaveNewsletterUnsubscriptionConfirmationMail(final RequestData requestData, final String velocityPath, final NewsletterEmailBean newsletterEmailBean) throws Exception { Email email = null; try { final String contextNameValue = requestData.getContextNameValue(); final Localization localization = requestData.getMarketAreaLocalization(); final Locale locale = localization.getLocale(); // SANITY CHECK checkEmailAddresses(newsletterEmailBean); Map<String, Object> model = new HashMap<String, Object>(); DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.FULL, locale); java.sql.Timestamp currentDate = new java.sql.Timestamp((new java.util.Date()).getTime()); model.put(CURRENT_DATE, dateFormatter.format(currentDate)); model.put("newsletterEmailBean", newsletterEmailBean); model.put(WORDING, coreMessageSource.loadWording(Email.WORDING_SCOPE_EMAIL, locale)); Map<String, String> urlParams = new HashMap<String, String>(); urlParams.put(RequestConstants.REQUEST_PARAMETER_NEWSLETTER_EMAIL, URLEncoder.encode(newsletterEmailBean.getToEmail(), Constants.ANSI)); String subscribeUrl = urlService.generateUrl(FoUrls.NEWSLETTER_REGISTER, requestData, urlParams); model.put("subscribeUrl", urlService.buildAbsoluteUrl(requestData, subscribeUrl)); String unsubscribeUrl = urlService.generateUrl(FoUrls.NEWSLETTER_UNREGISTER, requestData, urlParams); String fullUnsubscribeUrl = urlService.buildAbsoluteUrl(requestData, unsubscribeUrl); model.put("unsubscribeUrlOrEmail", fullUnsubscribeUrl); String fromAddress = handleFromAddress(newsletterEmailBean.getFromAddress(), contextNameValue); String fromName = handleFromName(newsletterEmailBean.getFromName(), locale); String toEmail = newsletterEmailBean.getToEmail(); MimeMessagePreparatorImpl mimeMessagePreparator = getMimeMessagePreparator(requestData, Email.EMAIl_TYPE_NEWSLETTER_SUBSCRIPTION, model); // mimeMessagePreparator.setUnsubscribeUrlOrEmail(fullUnsubscribeUrl); mimeMessagePreparator.setTo(toEmail); mimeMessagePreparator.setFrom(fromAddress); mimeMessagePreparator.setFromName(fromName); mimeMessagePreparator.setReplyTo(fromAddress); Object[] parameters = {}; mimeMessagePreparator.setSubject(coreMessageSource .getMessage("email.newsletter_unsubscription.email_subject", parameters, locale)); mimeMessagePreparator.setHtmlContent(VelocityEngineUtils.mergeTemplateIntoString(getVelocityEngine(), velocityPath + "newsletter-unsubscription-confirmation-html-content.vm", model)); mimeMessagePreparator .setPlainTextContent(VelocityEngineUtils.mergeTemplateIntoString(getVelocityEngine(), velocityPath + "newsletter-unsubscription-confirmation-text-content.vm", model)); email = new Email(); email.setType(Email.EMAIl_TYPE_NEWSLETTER_SUBSCRIPTION); email.setStatus(Email.EMAIl_STATUS_PENDING); saveOrUpdateEmail(email, mimeMessagePreparator); } catch (MailException e) { logger.error("Error, can't save the message :", e); throw e; } catch (VelocityException e) { logger.error("Error, can't build the message :", e); throw e; } catch (IOException e) { logger.error("Error, can't serializable the message :", e); throw e; } return email; }
From source file:org.rhq.enterprise.server.measurement.util.MeasurementDataManagerUtility.java
public static String getNextRotationTime() { long now = System.currentTimeMillis(); long day = now / MILLISECONDS_PER_DAY; long timeOfDay = now - (day * MILLISECONDS_PER_DAY); long remaining = MILLISECONDS_PER_TABLE - timeOfDay; long nextRotation = now + remaining; if (nextRotation < now) { nextRotation += MILLISECONDS_PER_TABLE; }/*from w ww . j ava 2 s . c o m*/ return DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.FULL).format(new Date(nextRotation)); }
From source file:fr.hoteia.qalingo.core.service.impl.EmailServiceImpl.java
/** * @throws Exception //from www . j a v a 2 s. com * @see fr.hoteia.qalingo.core.service.EmailService#buildAndSaveCustomerForgottenPasswordMail(Localization localization, Customer customer, String velocityPath, CustomerForgottenPasswordEmailBean customerForgottenPasswordEmailBean) */ public void buildAndSaveCustomerForgottenPasswordMail(final RequestData requestData, final Customer customer, final String velocityPath, final CustomerForgottenPasswordEmailBean customerForgottenPasswordEmailBean) throws Exception { try { final Localization localization = requestData.getLocalization(); final Locale locale = localization.getLocale(); // SANITY CHECK checkEmailAddresses(customerForgottenPasswordEmailBean); Map<String, Object> model = new HashMap<String, Object>(); DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.FULL, locale); java.sql.Timestamp currentDate = new java.sql.Timestamp((new java.util.Date()).getTime()); model.put("currentDate", dateFormatter.format(currentDate)); model.put("customer", customer); model.put("wording", coreMessageSource.loadWording(Email.WORDING_SCOPE_EMAIL, locale)); Map<String, String> urlParams = new HashMap<String, String>(); urlParams.put(RequestConstants.REQUEST_PARAMETER_PASSWORD_RESET_EMAIL, customer.getEmail()); urlParams.put(RequestConstants.REQUEST_PARAMETER_PASSWORD_RESET_TOKEN, customerForgottenPasswordEmailBean.getToken()); String resetPasswordUrl = urlService.generateUrl(FoUrls.RESET_PASSWORD, requestData, urlParams); model.put("resetPasswordUrl", resetPasswordUrl); model.put("customerForgottenPasswordEmailBean", customerForgottenPasswordEmailBean); String fromEmail = customerForgottenPasswordEmailBean.getFromEmail(); MimeMessagePreparatorImpl mimeMessagePreparator = getMimeMessagePreparator(requestData, Email.EMAIl_TYPE_FORGOTTEN_PASSWORD, model); mimeMessagePreparator.setTo(customer.getEmail()); mimeMessagePreparator.setFrom(fromEmail); mimeMessagePreparator.setFromName(coreMessageSource.getMessage("email.common.from_name", locale)); mimeMessagePreparator.setReplyTo(fromEmail); Object[] parameters = { customer.getLastname(), customer.getFirstname() }; mimeMessagePreparator.setSubject( coreMessageSource.getMessage("email.forgotten_password.email_subject", parameters, locale)); mimeMessagePreparator.setHtmlContent(VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, velocityPath + "forgotten-password-html-content.vm", model)); mimeMessagePreparator.setPlainTextContent(VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, velocityPath + "forgotten-password-text-content.vm", model)); Email email = new Email(); email.setType(Email.EMAIl_TYPE_FORGOTTEN_PASSWORD); email.setStatus(Email.EMAIl_STATUS_PENDING); saveOrUpdateEmail(email, mimeMessagePreparator); } catch (MailException e) { LOG.error("Error, can't save the message :", e); throw e; } catch (VelocityException e) { LOG.error("Error, can't build the message :", e); throw e; } catch (IOException e) { LOG.error("Error, can't serializable the message :", e); throw e; } }
From source file:org.methodize.nntprss.admin.AdminServlet.java
private void writeChannel(Writer writer, Channel channel, HttpServletRequest request, boolean refresh) throws IOException { if (channel == null) { writer.write("<b>Channel " + channel.getName() + " not found!</b>"); } else {//from w ww. j ava2 s .c o m ChannelManager channelManager = (ChannelManager) getServletContext() .getAttribute(AdminServer.SERVLET_CTX_RSS_MANAGER); DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL); String url = ((!refresh) ? channel.getUrl() : request.getParameter("URL")); boolean enabled = ((!refresh) ? channel.isEnabled() : isChecked(request, "enabled")); boolean parseAtAllCost = ((!refresh) ? channel.isParseAtAllCost() : isChecked(request, "parseAtAllCost")); // boolean historical = ((!refresh) ? channel.isHistorical() : isChecked(request, "historical")); boolean postingEnabled = ((!refresh) ? channel.isPostingEnabled() : (!request.getParameter("postingEnabled").equals("false"))); String publishAPI = ((!refresh) ? channel.getPublishAPI() : request.getParameter("publishAPI")); // long pollingIntervalSeconds = // ((!refresh) // ? channel.getPollingIntervalSeconds() // : Long.parseLong(request.getParameter("pollingInterval"))); // long expiration = // ((!refresh) // ? channel.getExpiration() // : Long.parseLong(request.getParameter("expiration"))); int categoryId = 0; if (!refresh) { if (channel.getCategory() != null) { categoryId = channel.getCategory().getId(); } } else { categoryId = Integer.parseInt(request.getParameter("categoryId")); } writer.write("<form name='channel' action='?action=update' method='POST'>"); writer.write( "<input type='hidden' name='name' value='" + HTMLHelper.escapeString(channel.getName()) + "'>"); writer.write("<table class='tableborder'>"); writer.write("<tr><th class='tableHead' colspan='2'>Channel Configuration</th></tr>"); writer.write("<tr><td class='row1' align='right'>Title</td><td class='row2'>" + HTMLHelper.escapeString(channel.getTitle() == null ? "Unknown" : channel.getTitle()) + "</td></tr>"); writer.write("<tr><td class='row1' align='right'>Newsgroup Name</td><td class='row2'>" + HTMLHelper.escapeString(channel.getName()) + "</td></tr>"); writer.write( "<tr><td class='row1' align='right'>URL</td><td class='row2'><input type='text' name='URL' value='" + HTMLHelper.escapeString(url) + "' size='64'></td></tr>"); writer.write("<tr><td class='row1' align='right'>Polling</td><td class='row2'>" + "<input name='enabled' type='checkbox' value='true' " + (enabled ? "checked>" : ">") + "</td></tr>"); writer.write("<tr><td class='row1' align='right'>Polling Interval</td>"); writer.write("<td class='row2'><select name='pollingInterval'>"); if (channel.getPollingIntervalSeconds() == Channel.DEFAULT_POLLING_INTERVAL) { writer.write("<option selected value='" + Channel.DEFAULT_POLLING_INTERVAL + "'>Use Default Polling Interval\n"); } else { writer.write("<option selected value='" + channel.getPollingIntervalSeconds() + "'>" + channel.getPollingIntervalSeconds() / 60 + " minutes\n"); } writer.write("<option value='" + Channel.DEFAULT_POLLING_INTERVAL + "'>Use Default Polling Interval\n"); for (int interval = 10; interval <= 120; interval += 10) { writer.write("<option value='" + (interval * 60) + "'>" + interval + " minutes\n"); } writer.write("</select></td></tr>"); writer.write( "<tr><td class='row1' align='right'>Parse-at-all-costs</td><td class='row2'><input name='parseAtAllCost' type='checkbox' value='true' " + (parseAtAllCost ? "checked>" : ">") + "<br><i>This will enable the experimental parse-at-all-costs RSS parser. This feature supports the parsing of badly-formatted RSS feeds.</i></td></tr>"); writer.write("<tr><td class='row1' align='right'>Status</td>"); switch (channel.getStatus()) { case Channel.STATUS_NOT_FOUND: writer.write( "<td class='chlerror' bgcolor='#FF0000'><font color='#FFFFFF'>Feed Web Server is returning File Not Found.</font>"); break; case Channel.STATUS_INVALID_CONTENT: writer.write( "<td class='chlerror' bgcolor='#FF0000'><font color='#FFFFFF'>Last feed document retrieved could not be parsed, <a class='chlerror' target='validate' href='http://feedvalidator.org/check?url=" + HTMLHelper.escapeString(url) + "'>check URL</a>.</font>"); break; case Channel.STATUS_UNKNOWN_HOST: writer.write( "<td class='chlerror' bgcolor='#FF0000'><font color='#FFFFFF'>Unable to contact Feed Web Server (Unknown Host). Check URL.</font>"); break; case Channel.STATUS_NO_ROUTE_TO_HOST: writer.write( "<td class='chlerror' bgcolor='#FF0000'><font color='#FFFFFF'>Unable to contact Feed Web Server (No Route To Host). Check URL.</font>"); break; case Channel.STATUS_CONNECTION_TIMEOUT: writer.write( "<td class='chlwarning' bgcolor='#FFFF00'><font color='#000000'>Currently unable to contact Feed Web Server (Connection timeout).</font>"); break; case Channel.STATUS_SOCKET_EXCEPTION: writer.write( "<td class='chlwarning' bgcolor='#FFFF00'><font color='#000000'>Currently unable to contact Feed Web Server (Socket exception).</font>"); break; case Channel.STATUS_PROXY_AUTHENTICATION_REQUIRED: writer.write( "<td class='chlerror' bgcolor='#FFFF00'><font color='#FFFFFF'>Proxy authentication required. Please configure user name and password in <a class='chlerror' href='?action=showconfig'>System Configuration</a>.</font>"); break; case Channel.STATUS_USER_AUTHENTICATION_REQUIRED: writer.write( "<td class='chlerror' bgcolor='#FFFF00'><font color='#FFFFFF'>User authentication required. Please specific user name and password in the URL, e.g.<br>http://username:password@www.myhost.com/feed.xml</font>"); break; default: writer.write("<td class='row2'>OK"); } writer.write("</td></tr>"); writer.write("<tr><td class='row1' align='right'>Last Polled</td><td class='row2'>" + ((channel.getLastPolled() == null) ? "Yet to be polled." : df.format(channel.getLastPolled())) + "</td></tr>"); writer.write("<tr><td class='row1' align='right'>Last Modified</td><td class='row2'>"); if (channel.getLastModified() == 0) { writer.write("Last modified not supplied by Feed Web Server"); } else { writer.write(df.format(new Date(channel.getLastModified()))); } writer.write("</td></tr>"); writer.write("<tr><td class='row1' align='right'>Last ETag</td><td class='row2'>"); if (channel.getLastETag() == null) { writer.write("ETag not supplied by Feed Web Server"); } else { writer.write(channel.getLastETag()); } writer.write("</td></tr>"); writer.write("<tr><td class='row1' align='right'>Feed Type</td><td class='row2'>"); if (channel.getRssVersion() == null) { writer.write("Unknown"); } else { writer.write(channel.getRssVersion()); } writer.write("</td></tr>"); // writer.write("<tr><td class='row1' align='right'>Historical</td><td class='row2'><input name='historical' type='checkbox' value='true' " // + (historical ? "checked>" : ">") // + "</td></tr>"); writeExpiration(writer, channel); writer.write("<tr><td class='row1' align='right'>Category</td>"); writer.write("<td class='row2'><select name='categoryId'>"); writeOption(writer, "[No Category]", 0, categoryId); Iterator categories = channelManager.categories(); while (categories.hasNext()) { Category category = (Category) categories.next(); writeOption(writer, category.getName(), category.getId(), categoryId); } writer.write("</select></td></tr>"); writer.write("<tr><td class='row1' align='right'>Managing Editor</td><td class='row2'>"); if (channel.getManagingEditor() != null) { writer.write( "<a href='mailto:" + URLEncoder.encode(RSSHelper.parseEmail(channel.getManagingEditor())) + "'>" + HTMLHelper.escapeString(channel.getManagingEditor()) + "</a>"); } else { writer.write("Unknown"); } writer.write("</td></tr>"); writer.write( "<tr><td class='row1' align='right'>Posting</td><td class='row2'><select name='postingEnabled' onChange='this.form.action=\"?action=editchlrefresh\"; this.form.submit();'>" + "<option " + (postingEnabled ? "selected" : "") + ">true" + "<option " + (!postingEnabled ? "selected" : "") + ">false" + "</select></td></tr>"); if (postingEnabled) { writer.write("<tr><th class='subHead' colspan='2' align='center'>Posting Configuration</td></tr>"); writer.write( "<tr><td class='row1' align='right'>API</td><td class='row2'><select name='publishAPI' onChange='this.form.action=\"?action=editchlrefresh&publishapichange=true\"; this.form.submit();'>" + "<option value='blogger' " + (publishAPI == null || publishAPI.equals("blogger") ? "selected" : "") + ">Blogger" + "<option value='livejournal' " + (publishAPI != null && publishAPI.equals("livejournal") ? "selected" : "") + ">LiveJournal" + "<option value='metaweblog' " + (publishAPI != null && publishAPI.equals("metaweblog") ? "selected" : "") + ">MetaWeblog" // + "<option " + (!postingEnabled ? "selected" : "") + ">false" + "</select></td></tr>"); if (publishAPI == null || publishAPI.equals("blogger")) { // Default API String publishUrl = null; String blogId = null; String userName = null; String password = null; boolean autoPublish = true; if (refresh) { // If a refresh, get the parameter values from the parameter collection if (request.getParameter("publishapichange") == null) { publishUrl = request.getParameter(BloggerPublisher.PROP_PUBLISHER_URL); } blogId = (String) request.getParameter(BloggerPublisher.PROP_BLOG_ID); userName = (String) request.getParameter(BloggerPublisher.PROP_USERNAME); password = (String) request.getParameter(BloggerPublisher.PROP_PASSWORD); String autoPublishStr = request.getParameter(BloggerPublisher.PROP_PUBLISH); autoPublish = (autoPublishStr != null && autoPublishStr.equals("false")) ? false : true; } else { // If a initial channel view, extract parameter from the Channel publish config map Map publishConfig = channel.getPublishConfig(); if (publishConfig != null) { publishUrl = (String) publishConfig.get(BloggerPublisher.PROP_PUBLISHER_URL); blogId = (String) publishConfig.get(BloggerPublisher.PROP_BLOG_ID); userName = (String) publishConfig.get(BloggerPublisher.PROP_USERNAME); password = (String) publishConfig.get(BloggerPublisher.PROP_PASSWORD); if (password != null) password = PASSWORD_MAGIC_KEY; String autoPublishStr = (String) publishConfig.get(BloggerPublisher.PROP_PUBLISH); autoPublish = (autoPublishStr != null && autoPublishStr.equals("false")) ? false : true; } } // Make sure that everything has a value, especially if publish has just been enabled if (publishUrl == null) publishUrl = "http://plant.blogger.com/api/RPC2"; if (blogId == null) blogId = ""; if (userName == null) userName = ""; if (password == null) password = ""; writer.write("<tr><td class='row1' align='right'>URL</td>"); writer.write("<td class='row2'><input name='" + BloggerPublisher.PROP_PUBLISHER_URL + "' type='text' size='64' value='" + HTMLHelper.escapeString(publishUrl) + "'></td></tr>"); writer.write("<tr><td class='row1' align='right'>Blog Id</td>"); writer.write("<td class='row2'><input name='" + BloggerPublisher.PROP_BLOG_ID + "' type='text' value='" + HTMLHelper.escapeString(blogId) + "'></td></tr>"); writer.write("<tr><td class='row1' align='right'>Username</td>"); writer.write("<td class='row2'><input name='" + BloggerPublisher.PROP_USERNAME + "' type='text' value='" + HTMLHelper.escapeString(userName) + "'></td></tr>"); writer.write("<tr><td class='row1' align='right'>Password</td>"); writer.write("<td class='row2'><input name='" + BloggerPublisher.PROP_PASSWORD + "' type='password' value='" + HTMLHelper.escapeString(password) + "'></td></tr>"); writer.write("<tr><td class='row1' align='right'>Auto Publish</td>"); writer.write("<td class='row2'><input name='" + BloggerPublisher.PROP_PUBLISH + "' type='checkbox' value='true' " + (autoPublish ? "checked" : "") + "></td></tr>"); } else if (publishAPI.equals("metaweblog")) { String publishUrl = null; String blogId = null; String userName = null; String password = null; boolean autoPublish = true; if (refresh) { // If a refresh, get the parameter values from the parameter collection if (request.getParameter("publishapichange") == null) { publishUrl = request.getParameter(MetaWeblogPublisher.PROP_PUBLISHER_URL); } blogId = (String) request.getParameter(BloggerPublisher.PROP_BLOG_ID); if (blogId != null && blogId.length() == 0) blogId = "home"; userName = (String) request.getParameter(MetaWeblogPublisher.PROP_USERNAME); password = (String) request.getParameter(MetaWeblogPublisher.PROP_PASSWORD); String autoPublishStr = request.getParameter(MetaWeblogPublisher.PROP_PUBLISH); autoPublish = (autoPublishStr != null && autoPublishStr.equals("false")) ? false : true; } else { // If a initial channel view, extract parameter from the Channel publish config map Map publishConfig = channel.getPublishConfig(); if (publishConfig != null) { publishUrl = (String) publishConfig.get(MetaWeblogPublisher.PROP_PUBLISHER_URL); userName = (String) publishConfig.get(MetaWeblogPublisher.PROP_USERNAME); password = (String) publishConfig.get(MetaWeblogPublisher.PROP_PASSWORD); if (password != null) password = PASSWORD_MAGIC_KEY; String autoPublishStr = (String) publishConfig.get(MetaWeblogPublisher.PROP_PUBLISH); autoPublish = (autoPublishStr != null && autoPublishStr.equals("false")) ? false : true; } } // Make sure that everything has a value, especially if publish has just been enabled if (publishUrl == null) publishUrl = "http://127.0.0.1:5335/RPC2"; if (blogId == null) blogId = "home"; if (userName == null) userName = ""; if (password == null) password = ""; writer.write("<tr><td class='row1' align='right'>URL</td>"); writer.write("<td class='row2'><input name='" + MetaWeblogPublisher.PROP_PUBLISHER_URL + "' type='text' size='64' value='" + HTMLHelper.escapeString(publishUrl) + "'><br><i>Ensure that the URL points to your MetaWeblog (e.g. Radio Userland) host</i></td></tr>"); writer.write("<tr><td class='row1' align='right'>Blog Id</td>"); writer.write("<td class='row2'><input name='" + BloggerPublisher.PROP_BLOG_ID + "' type='text' value='" + HTMLHelper.escapeString(blogId) + "'></td></tr>"); writer.write("<tr><td class='row1' align='right'>Username</td>"); writer.write("<td class='row2'><input name='" + MetaWeblogPublisher.PROP_USERNAME + "' type='text' value='" + HTMLHelper.escapeString(userName) + "'></td></tr>"); writer.write("<tr><td class='row1' align='right'>Password</td>"); writer.write("<td class='row2'><input name='" + MetaWeblogPublisher.PROP_PASSWORD + "' type='password' value='" + HTMLHelper.escapeString(password) + "'></td></tr>"); writer.write("<tr><td class='row1' align='right'>Auto Publish</td>"); writer.write("<td class='row2'><input name='" + MetaWeblogPublisher.PROP_PUBLISH + "' type='checkbox' value='true' " + (autoPublish ? "checked" : "") + "></td></tr>"); } else if (publishAPI.equals("livejournal")) { String publishUrl = null; String userName = null; String password = null; if (refresh) { // If a refresh, get the parameter values from the parameter collection if (request.getParameter("publishapichange") == null) { publishUrl = request.getParameter(LiveJournalPublisher.PROP_PUBLISHER_URL); } userName = (String) request.getParameter(LiveJournalPublisher.PROP_USERNAME); password = (String) request.getParameter(LiveJournalPublisher.PROP_PASSWORD); } else { // If a initial channel view, extract parameter from the Channel publish config map Map publishConfig = channel.getPublishConfig(); if (publishConfig != null) { publishUrl = (String) publishConfig.get(LiveJournalPublisher.PROP_PUBLISHER_URL); userName = (String) publishConfig.get(LiveJournalPublisher.PROP_USERNAME); password = (String) publishConfig.get(LiveJournalPublisher.PROP_PASSWORD); if (password != null) password = PASSWORD_MAGIC_KEY; } } // Make sure that everything has a value, especially if publish has just been enabled if (publishUrl == null) publishUrl = "http://www.livejournal.com/interface/xmlrpc"; if (userName == null) userName = ""; if (password == null) password = ""; writer.write("<tr><td class='row1' align='right'>URL</td>"); writer.write("<td class='row2'><input name='" + LiveJournalPublisher.PROP_PUBLISHER_URL + "' type='text' size='64' value='" + HTMLHelper.escapeString(publishUrl) + "'><br></td></tr>"); writer.write("<tr><td class='row1' align='right'>Username</td>"); writer.write("<td class='row2'><input name='" + LiveJournalPublisher.PROP_USERNAME + "' type='text' value='" + HTMLHelper.escapeString(userName) + "'></td></tr>"); writer.write("<tr><td class='row1' align='right'>Password</td>"); writer.write("<td class='row2'><input name='" + LiveJournalPublisher.PROP_PASSWORD + "' type='password' value='" + HTMLHelper.escapeString(password) + "'></td></tr>"); } } writer.write( "<tr><td class='row2' align='center' colspan='2'><input type='submit' name='update' value='Update'> <input type='submit' name='delete' onClick='return confirm(\"Are you sure you want to delete this channel?\");' value='Delete'></td></tr>"); writer.write("</table>"); writer.write("</form>"); } }
From source file:net.sf.jasperreports.functions.standard.DateTimeFunctions.java
/** * This methods tries to convert a generic object into a java.util.Date instance. * Supported types are for now String, Long values (time millis) and Date subtypes * like for example java.sql.Date./*from w w w . j a v a 2 s . com*/ */ private Date convertDateObject(Object dateObject) { if (dateObject == null) { if (log.isDebugEnabled()) { log.debug("The date object can not be null."); } return null; } else if (dateObject instanceof String) { // Try to convert using the different style for pattern. // We use MEDIUM as the first one because it is the DEFAULT int formatTypes[] = new int[] { DateFormat.MEDIUM, DateFormat.SHORT, DateFormat.LONG, DateFormat.FULL }; for (int formatType : formatTypes) { try { DateFormat df = DateFormat.getDateInstance(formatType, getReportLocale()); df.setTimeZone(getReportTimeZone()); return df.parse((String) dateObject); } catch (ParseException e) { if (log.isDebugEnabled()) { log.debug("Unable to parse the string as Date using the standard SimpleDateFormat."); } } } return null; } else if (dateObject instanceof Long) { Calendar cal = Calendar.getInstance(getReportTimeZone(), getReportLocale()); cal.setTimeInMillis((Long) dateObject); return cal.getTime(); } else if (dateObject instanceof Date) { return (Date) dateObject; } if (log.isDebugEnabled()) { log.debug("The specified object is not among the allowed types for Date conversion."); } return null; }