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:org.opencms.i18n.CmsMessages.java

/**
 * Returns a formated date and time String from a timestamp value,
 * the format being {@link DateFormat#SHORT} and the locale
 * based on this instance.<p>// w ww  . java  2  s.  co  m
 * 
 * @param time the time value to format as date
 * @return the formatted date and time
 */
public String getDateTime(long time) {

    return CmsDateUtil.getDateTime(new Date(time), DateFormat.SHORT, m_locale);
}

From source file:com.eleybourn.bookcatalogue.utils.Utils.java

/**
 * Attempt to parse a date string based on a range of possible formats; allow
 * for caller to specify if the parsing should be strict or lenient.
 * /*from ww w  .  j  a v  a 2  s  .  c o m*/
 * @param s            String to parse
 * @param lenient      True if parsing should be lenient
 * 
 * @return            Resulting date if parsed, otherwise null
 */
private static Date parseDate(String s, boolean lenient) {
    Date d;
    for (SimpleDateFormat sdf : mParseDateFormats) {
        try {
            sdf.setLenient(lenient);
            d = sdf.parse(s);
            return d;
        } catch (Exception e) {
            // Ignore 
        }
    }
    // All SDFs failed, try locale-specific...
    try {
        java.text.DateFormat df = java.text.DateFormat.getDateInstance(java.text.DateFormat.SHORT);
        df.setLenient(lenient);
        d = df.parse(s);
        return d;
    } catch (Exception e) {
        // Ignore 
    }
    return null;
}

From source file:org.apache.roller.weblogger.ui.struts2.util.UIAction.java

public String getShortDateFormat() {
    DateFormat sdf = DateFormat.getDateInstance(DateFormat.SHORT, getLocale());
    if (sdf instanceof SimpleDateFormat) {
        return ((SimpleDateFormat) sdf).toPattern();
    }//from  w w  w .j a v a 2 s  .c o m
    return "yyyy/MM/dd";
}

From source file:com.appeligo.alerts.PendingAlertThread.java

public void run() {
    try {/*from  w  w  w.  ja  v  a  2  s.  com*/
        Permissions.setCurrentUser(Permissions.SUPERUSER);

        while (isActive()) {

            PendingAlert next = null;

            HibernateUtil.openSession();
            try {
                next = PendingAlert.getNextAlert();
            } finally {
                HibernateUtil.closeSession();
            }

            long delay = 0;
            if (next != null) {
                delay = next.getAlertTime().getTime() - System.currentTimeMillis();
                log.debug("current time=" + System.currentTimeMillis() + ", next alert time="
                        + next.getAlertTime().getTime());
            }

            while (((delay > 0) || (next == null)) && isActive()) {
                log.debug("Waiting for next pending alert. next=" + (next == null ? null : next.getId())
                        + ", time before next alert=" + delay);
                try {
                    synchronized (this) {
                        wait(delay); // value can only be zero (as initialized) or
                                     // a positive value (as checked in while condition).
                                     // wait(0) == wait forever
                    }
                } catch (InterruptedException e) {
                }
                //need to see if there is a newer alert
                //(in which case, notifyAll was called), or the
                //alert we were waiting for was deleted
                delay = 0;
                HibernateUtil.openSession();
                try {
                    next = PendingAlert.getNextAlert();
                } finally {
                    HibernateUtil.closeSession();
                }
                if (next != null) {
                    delay = next.getAlertTime().getTime() - System.currentTimeMillis();
                    log.debug("current time=" + System.currentTimeMillis() + ", next alert time="
                            + next.getAlertTime().getTime());
                }
            }

            if (isActive())
                log.debug("Ready to fire off at least one pending alert. next=" + next.getId() + ", deleted="
                        + next.isDeleted());

            HibernateUtil.openSession();
            List<PendingAlert> pendingAlerts = PendingAlert.getExpiredAlerts();
            try {
                if (isActive())
                    log.debug("checking next");
                for (PendingAlert pendingAlert : pendingAlerts) {
                    if (!isActive()) {
                        break;
                    }
                    log.debug("next");
                    User user = null;
                    int consecutiveExceptions = 0;
                    Transaction transaction = HibernateUtil.currentSession().beginTransaction();
                    try {
                        if (pendingAlert.isDeleted()) {
                            log.debug("deleted");
                            continue;
                        }
                        ProgramAlert programAlert = pendingAlert.getProgramAlert();
                        if (programAlert == null) { // then this should be a manual pending alert
                            pendingAlert.setDeleted(true);
                            pendingAlert.save();
                            if (!pendingAlert.isManual()) {
                                log.debug("no program alert");
                                continue;
                            }
                        }
                        user = pendingAlert.getUser();
                        String programId = pendingAlert.getProgramId();
                        if (user == null || programId == null) {
                            log.debug("user (" + user + ") can't be null and programId (" + programId
                                    + ") can't be null");
                            if (programAlert != null) {
                                programAlert.setDeleted(true);
                                programAlert.save();
                            }
                            continue;
                        }
                        ScheduledProgram scheduledProgram = alertManager.getEpg()
                                .getScheduledProgramByNetworkCallSign(pendingAlert.getUser().getLineupId(),
                                        pendingAlert.getCallSign(), pendingAlert.getProgramStartTime());
                        String targetId;
                        if (programAlert == null) {
                            targetId = scheduledProgram.getProgramId();
                        } else {
                            targetId = programAlert.getProgramId();
                            // not a manual alert, so this is the id for the reminder itself
                        }
                        Program targetProgram = alertManager.getEpg().getProgram(targetId);

                        boolean invalidProgramAlert = false;

                        if (scheduledProgram == null) {
                            if (log.isDebugEnabled())
                                log.debug("no scheduled program");
                        } else {
                            if (!scheduledProgram.getProgramId().equals(programId)) {
                                invalidProgramAlert = true;
                                if (log.isDebugEnabled())
                                    log.debug("Schedule must have changed...no matching programId: "
                                            + scheduledProgram.getProgramId() + " != " + programId);
                            } else if (programAlert != null) { // Not a manual (quick) alert
                                if (programAlert.isDisabled()) {
                                    invalidProgramAlert = true;
                                    if (log.isDebugEnabled())
                                        log.debug("program alert disabled");
                                } else if (programAlert.isDeleted()) {
                                    invalidProgramAlert = true;
                                    if (log.isDebugEnabled())
                                        log.debug("program alert was deleted");
                                }
                            }
                        }

                        if ((scheduledProgram != null) && (!invalidProgramAlert)) {

                            boolean scheduledAlert = false;
                            boolean episodeAlert = false;
                            if (programAlert == null) {
                                scheduledAlert = true;
                            } else {
                                episodeAlert = true;
                            }

                            log.debug("firing pending alert=" + pendingAlert.getId());

                            Date startTime = scheduledProgram.getStartTime();
                            Date endTime = scheduledProgram.getEndTime();

                            long durationMinutes = (endTime.getTime() - startTime.getTime()) / (60 * 1000);

                            Map<String, String> context = new HashMap<String, String>();

                            DateFormat format = null;
                            DateFormat shortFormat = null;
                            if ((startTime.getTime() - System.currentTimeMillis()) < 12 * 60 * 60 * 1000) {
                                format = DateFormat.getTimeInstance(DateFormat.SHORT);
                                shortFormat = DateFormat.getTimeInstance(DateFormat.SHORT);
                                context.put("timePreposition", "at");
                            } else {
                                shortFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT,
                                        DateFormat.SHORT);
                                format = new SimpleDateFormat("EEEE, MMMM d 'at' h:mm a");
                                context.put("timePreposition", "on");
                            }
                            format.setTimeZone(user.getTimeZone());
                            shortFormat.setTimeZone(user.getTimeZone());
                            context.put("startTime", format.format(startTime));
                            context.put("shortStartTime", shortFormat.format(startTime));

                            context.put("durationMinutes", Long.toString(durationMinutes));
                            context.put("programId", scheduledProgram.getProgramId()); // don't use ID from programAlert
                            // which may be a show, but this may be an episode, or may be a team, but this a game
                            String webPath = scheduledProgram.getWebPath();
                            if (webPath.charAt(0) == '/') {
                                webPath = webPath.substring(1);
                            }
                            context.put("webPath", webPath);
                            context.put("targetId", targetId);
                            context.put("programLabel", scheduledProgram.getLabel());
                            if (targetId.startsWith("TE")) {
                                context.put("whatfor", "any game featuring the " + targetProgram.getTeamName());
                                context.put("reducedTitle40", targetProgram.getReducedTitle40());
                            } else {
                                context.put("whatfor", "the following program");
                                context.put("reducedTitle40", scheduledProgram.getReducedTitle40());
                            }
                            if (scheduledProgram.getDescription().trim().length() > 0) {
                                context.put("description",
                                        "Description: " + scheduledProgram.getDescription() + "<br/>");
                            } else {
                                context.put("description", "");
                            }
                            context.put("stationName", scheduledProgram.getNetwork().getStationName());
                            String greeting = user.getUsername();
                            context.put("username", greeting);
                            String firstName = user.getFirstName();
                            if (firstName != null && firstName.trim().length() > 0) {
                                greeting = firstName;
                            }
                            context.put("greeting", greeting);
                            String targetWebPath = targetProgram.getWebPath();
                            if (targetWebPath.charAt(0) == '/') {
                                targetWebPath = targetWebPath.substring(1);
                            }
                            context.put("showDetailsLink", "<a href=\"" + url + targetWebPath + "#reminders\">"
                                    + url + targetWebPath + "#reminders</a>");
                            if (episodeAlert) {
                                context.put("deleteRemindersSentence",
                                        "Did you already see this program? If you're done with this reminder, "
                                                + "<a href=\"" + url
                                                + "reminders/deleteProgramReminders?programId=" + targetId
                                                + "\">click here to delete the reminders for this program</a>.");
                                /*
                                LATER, REPLACE THE LAST PARAGRAPH ABOVE WITH...
                                <p>
                                Did you already see this program?  <a href="${url}reminders/deleteProgramReminders?programId=@programId@">Click
                                here to delete the reminders for this program</a>\, and if you don't mind\, tell us what you think.
                                </p>
                                AND PUT A SIMILAR MESSAGE WITHOUT THE DELETE BUT WITH A LINK IN IF NOT EPISODEREMINDER, in "ELSE" BELOW
                                    */
                            } else {
                                context.put("deleteRemindersSentence", "");
                            }
                            if ((programAlert != null && programAlert.isUsingPrimaryEmail())
                                    || user.isUsingPrimaryEmailDefault()) {
                                Message message = new Message("program_reminder_email", context);
                                if ((startTime.getTime() - System.currentTimeMillis()) > 4 * 60 * 60 * 1000) {
                                    message.setPriority(2);
                                }
                                message.setUser(user);
                                message.setTo(user.getPrimaryEmail());
                                message.insert();
                            }
                            if ((programAlert != null && programAlert.isUsingSMS()
                                    && user.getSmsEmail().trim().length() > 0) || user.isUsingSMSDefault()) {
                                Message message = new Message("program_reminder_sms", context);
                                if ((startTime.getTime() - System.currentTimeMillis()) > 4 * 60 * 60 * 1000) {
                                    message.setPriority(2);
                                }
                                message.setUser(user);
                                message.setTo(user.getSmsEmail());
                                message.setSms(true);
                                message.insert();
                            }
                        }
                        consecutiveExceptions = 0;
                    } catch (MessageContextException e) {
                        log.error(
                                "Software bug resulted in exception with email message context or configuration",
                                e);
                    } catch (Throwable t) {
                        log.error("Could not complete pending alert execution", t);
                        transaction.rollback();
                        log.error("Caught throwable on pendingAlert " + pendingAlert.getId() + ", user "
                                + ((user == null) ? null : user.getUsername()), t);
                        consecutiveExceptions++;
                        if (consecutiveExceptions >= maxConsecutiveExceptions) {
                            log.fatal(
                                    "Reached max consecutive exceptions for PendingAlertThread. Exiting thread immediately.");
                            return;
                        }
                    } finally {
                        if (transaction.wasRolledBack()) {
                            transaction = HibernateUtil.currentSession().beginTransaction();
                        }
                        try {
                            log.debug("marking pending alert=" + pendingAlert.getId()
                                    + " as fired. Should see commit message next.");
                            pendingAlert.setFired(true);
                            pendingAlert.save();
                            log.debug("committing after marking pending alert");
                        } catch (Throwable t) {
                            log.error("Coult not mark pending alert", t);
                        } finally {
                            transaction.commit();
                        }
                    }
                }

                // Now that we aren't looping on PendingAlerts, I should be able to safely
                // delete all of the PendingAlerts flagged as deleted without screwing up
                // paging (if we decide to implement paging up above)
                Transaction transaction = HibernateUtil.currentSession().beginTransaction();
                try {
                    log.debug("deleting marked-deleted pending alerts");
                    PendingAlert.deleteAllMarkedDeleted();
                    log.debug("deleted marked-deleted pending alerts");
                    log.debug("deleting marked-fired pending alerts if program has started");
                    PendingAlert.deleteOldFired();
                    log.debug("deleted marked-deleted pending alerts");
                } finally {
                    transaction.commit();
                }
            } finally {
                HibernateUtil.closeSession();
            }
        }
    } catch (Throwable t) {
        log.fatal("Caught unexpected exception, causing abort of thread!", t);
    }
}

From source file:net.sf.logsaw.dialect.websphere.WebsphereDialect.java

private DateFormat getDateFormat(Locale loc) throws CoreException {
    DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, loc);
    if (!(df instanceof SimpleDateFormat)) {
        return null;
    }//w  ww  . j  a  va  2  s  . co m
    try {
        // Always use US locale for date format symbols
        return new SimpleDateFormat(((SimpleDateFormat) df).toPattern() + " " + TIME_FORMAT, //$NON-NLS-1$
                DateFormatSymbols.getInstance(Locale.US));
    } catch (RuntimeException e) {
        // Could also be ClassCastException
        throw new CoreException(new Status(IStatus.ERROR, WebsphereDialectPlugin.PLUGIN_ID,
                NLS.bind(Messages.WebsphereDialect_error_dateFormatNotSupported, loc.toString())));
    }
}

From source file:Dates.java

public static String dateTimeFormatForJSCalendar(Locale locale) {
    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale);
    String datetime = df.format(create(1, 2, 1971, 15, 59, 0)); // d, m, y, hr, min, sec 
    boolean always4InYear = "es".equals(locale.getLanguage()) || "pl".equals(locale.getLanguage());
    String result = datetime./* ww w. java  2 s .com*/

    // time part
            replaceAll("15", "%H"). // 24hr format 
            replaceAll("03", "%I"). // 12hr format - double digit 
            replaceAll("3", "%l"). // 12hr format - single digit
            replaceAll("59", "%M"). // minute
            replaceAll("PM", "%p"). // AM/PM - uppercase
            replaceAll("pm", "%P"). // am/pm - lowercase

            // date part
            replaceAll("01", "%d"). // day - double digit
            replaceAll("02", "%m"). // month - double digit
            replaceAll("1971", "%Y"). // year - 4 digit
            replaceAll("71", always4InYear ? "%Y" : "%y"). // year - 2 digit     
            replaceAll("1", "%e"). // day - single digit
            replaceAll("2", "%m") // month - ??? seems only double digit is supported by calendar
    ;

    return result;
}

From source file:org.sakaiproject.signup.tool.jsf.organizer.action.SignupAction.java

public String getFormatTimeslotDateTime(SignupTimeslot timeslot) {

    final DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
    final char SEPARATOR = '-';
    StringBuilder sb = new StringBuilder();
    sb.append(df.format(timeslot.getStartTime()));
    sb.append(SEPARATOR);/*from  ww  w  .j ava 2  s.co  m*/
    sb.append(df.format(timeslot.getEndTime()));

    return sb.toString();
}

From source file:org.mifos.config.struts.action.CustomFieldsAction.java

private String changeDefaultValueDateToDBFormat(String defaultValue, Locale locale)
        throws InvalidDateException {
    SimpleDateFormat shortFormat = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, locale);
    String userfmt = DateUtils.convertToCurrentDateFormat(shortFormat.toPattern());
    return DateUtils.convertUserToDbFmt(defaultValue, userfmt);
}

From source file:de.mendelson.comm.as2.client.AS2Gui.java

/**
 * Creates new form NewJFrame//from   w  ww.ja v  a  2s  . co m
 */
public AS2Gui(Splash splash, String host) {
    this.host = host;
    //Set System default look and feel
    try {
        //support the command line option -Dswing.defaultlaf=...
        if (System.getProperty("swing.defaultlaf") == null) {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }
    } catch (Exception e) {
        this.logger.warning(this.getClass().getName() + ":" + e.getMessage());
    }
    //load resource bundle
    try {
        this.rb = (MecResourceBundle) ResourceBundle.getBundle(ResourceBundleAS2Gui.class.getName());
    } catch (MissingResourceException e) {
        throw new RuntimeException("Oops..resource bundle " + e.getClassName() + " not found.");
    }
    initComponents();
    this.jButtonNewVersion.setVisible(false);
    this.jPanelRefreshWarning.setVisible(false);
    //set preference values to the GUI
    this.setBounds(this.clientPreferences.getInt(PreferencesAS2.FRAME_X),
            this.clientPreferences.getInt(PreferencesAS2.FRAME_Y),
            this.clientPreferences.getInt(PreferencesAS2.FRAME_WIDTH),
            this.clientPreferences.getInt(PreferencesAS2.FRAME_HEIGHT));
    //ensure to display all messages
    this.getLogger().setLevel(Level.ALL);
    LogConsolePanel consolePanel = new LogConsolePanel(this.getLogger());
    //define the colors for the log levels
    consolePanel.setColor(Level.SEVERE, LogConsolePanel.COLOR_BROWN);
    consolePanel.setColor(Level.WARNING, LogConsolePanel.COLOR_BLUE);
    consolePanel.setColor(Level.INFO, LogConsolePanel.COLOR_BLACK);
    consolePanel.setColor(Level.CONFIG, LogConsolePanel.COLOR_DARK_GREEN);
    consolePanel.setColor(Level.FINE, LogConsolePanel.COLOR_DARK_GREEN);
    consolePanel.setColor(Level.FINER, LogConsolePanel.COLOR_DARK_GREEN);
    consolePanel.setColor(Level.FINEST, LogConsolePanel.COLOR_DARK_GREEN);
    this.jPanelServerLog.add(consolePanel);
    this.setTitle(AS2ServerVersion.getProductName() + " " + AS2ServerVersion.getVersion());
    //initialize the help system if available
    this.initializeJavaHelp();
    this.jTableMessageOverview.getSelectionModel().addListSelectionListener(this);
    this.jTableMessageOverview.getTableHeader().setReorderingAllowed(false);
    //icon columns
    TableColumn column = this.jTableMessageOverview.getColumnModel().getColumn(0);
    column.setMaxWidth(20);
    column.setResizable(false);
    column = this.jTableMessageOverview.getColumnModel().getColumn(1);
    column.setMaxWidth(20);
    column.setResizable(false);
    this.jTableMessageOverview.setDefaultRenderer(Date.class,
            new TableCellRendererDate(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)));
    //add row sorter
    RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(this.jTableMessageOverview.getModel());
    jTableMessageOverview.setRowSorter(sorter);
    sorter.addRowSorterListener(this);
    this.jPanelFilterOverview.setVisible(this.showFilterPanel);
    this.jMenuItemHelpForum.setEnabled(Desktop.isDesktopSupported());
    //destroy splash, possible login screen for the client should come up
    if (splash != null) {
        splash.destroy();
    }
    this.setButtonState();
    this.jTableMessageOverview.addMouseListener(this);
    //popup menu issues
    this.jPopupMenu.setInvoker(this.jScrollPaneMessageOverview);
    this.jPopupMenu.addPopupMenuListener(this);
    super.addMessageProcessor(this);
    //perform the connection to the server
    //warning! this works for localhost only so far
    int clientServerCommPort = this.clientPreferences.getInt(PreferencesAS2.CLIENTSERVER_COMM_PORT);
    if (splash != null) {
        splash.destroy();
    }
    this.browserLinkedPanel.cyleText(new String[] {
            "For additional EDI software to convert and process your data please contact <a href='http://www.mendelson-e-c.com'>mendelson-e-commerce GmbH</a>",
            "To buy a commercial license please visit the <a href='http://shop.mendelson-e-c.com/'>mendelson online shop</a>",
            "Most trading partners demand a trusted certificate - Order yours at the <a href='http://ca.mendelson-e-c.com'>mendelson CA</a> now!",
            "Looking for additional secure data transmission software? Try the <a href='http://oftp2.mendelson-e-c.com'>mendelson OFTP2</a> solution!",
            "You want to send EDIFACT data from your SAP system? Ask <a href='mailto:info@mendelson.de?subject=Please%20inform%20me%20about%20your%20SAP%20integration%20solutions'>mendelson-e-commerce GmbH</a> for a solution.",
            "You need a secure FTP solution? <a href='mailto:info@mendelson.de?subject=Please%20inform%20me%20about%20your%20SFTP%20solution'>Ask us</a> for the mendelson SFTP software.",
            "Convert flat files, EDIFACT, SAP IDos, VDA, inhouse formats? <a href='mailto:info@mendelson.de?subject=Please%20inform%20me%20about%20your%20converter%20solution'>Ask us</a> for the mendelson EDI converter.",
            "For commercial support of this software please buy a license at <a href='http://as2.mendelson-e-c.com'>the mendelson AS2</a> website.",
            "Have a look at the <a href='http://www.mendelson-e-c.com/products_mbi.php'>mendelson business integration</a> for a powerful EDI solution.",
            "The <a href='mailto:info@mendelson.de?subject=Please%20inform%20me%20about%20your%20RosettaNet%20solution'>mendelson RosettaNet solution</a> supports RNIF 1.1 and RNIF 2.0.",
            "The <a href='http://www.mendelson-e-c.com/products_ide.php'>mendelson converter IDE</a> is the graphical mapper for the mendelson converter.",
            "To process any XML data and convert it to EDIFACT, VDA, flat files, IDocs and inhouse formats use <a href='http://www.mendelson-e-c.com/products_converter.php'>the mendelson converter</a>.",
            "To transmit your EDI data via HTTP/S please <a href='mailto:info@mendelson.de?subject=Please%20inform%20me%20about%20your%20HTTPS%20solution'>ask us</a> for the mendelson HTTPS solution.",
            "If you have questions regarding this product please refer to the <a href='http://community.mendelson-e-c.com/'>mendelson community</a>.", });
    this.connect(new InetSocketAddress(host, clientServerCommPort), 5000);
    Runnable dailyNewsThread = new Runnable() {

        @Override
        public void run() {
            while (true) {
                long lastUpdateCheck = Long.valueOf(clientPreferences.get(PreferencesAS2.LAST_UPDATE_CHECK));
                //check only once a day even if the system is started n times a day
                if (lastUpdateCheck < (System.currentTimeMillis() - TimeUnit.HOURS.toMillis(23))) {
                    clientPreferences.put(PreferencesAS2.LAST_UPDATE_CHECK,
                            String.valueOf(System.currentTimeMillis()));
                    jButtonNewVersion.setVisible(false);
                    String version = (AS2ServerVersion.getVersion() + " " + AS2ServerVersion.getBuild())
                            .replace(' ', '+');
                    Header[] header = htmlPanel.setURL(
                            "http://www.mendelson.de/en/mecas2/client_welcome.php?version=" + version,
                            AS2ServerVersion.getProductName() + " " + AS2ServerVersion.getVersion(),
                            new File("start/client_welcome.html"));
                    if (header != null) {
                        String downloadURL = null;
                        String actualBuild = null;
                        for (Header singleHeader : header) {
                            if (singleHeader.getName().equals("x-actual-build")) {
                                actualBuild = singleHeader.getValue().trim();
                            }
                            if (singleHeader.getName().equals("x-download-url")) {
                                downloadURL = singleHeader.getValue().trim();
                            }
                        }
                        if (downloadURL != null && actualBuild != null) {
                            try {
                                int thisBuild = AS2ServerVersion.getBuildNo();
                                int availableBuild = Integer.valueOf(actualBuild);
                                if (thisBuild < availableBuild) {
                                    jButtonNewVersion.setVisible(true);
                                }
                                downloadURLNewVersion = downloadURL;
                            } catch (Exception e) {
                                //nop
                            }
                        }
                    }
                } else {
                    htmlPanel.setPage(new File("start/client_welcome.html"));
                }
                try {
                    //check once a day for new update
                    Thread.sleep(TimeUnit.DAYS.toMillis(1));
                } catch (InterruptedException e) {
                    //nop
                }
            }
        }
    };
    Executors.newSingleThreadExecutor().submit(dailyNewsThread);
    this.as2StatusBar.setConnectedHost(this.host);
}

From source file:org.nuxeo.ecm.platform.ui.web.tag.fn.Functions.java

/**
 * Return the date format to handle date taking the user's locale into account.
 *
 * @since 5.9.1/*from  ww  w .  j a  v a2s.  com*/
 */
public static String dateFormatter(String formatLength) {
    // A map to store temporary available date format
    FacesContext context = FacesContext.getCurrentInstance();
    Locale locale = context.getViewRoot().getLocale();

    int style = DateFormat.SHORT;
    String styleString = mapOfDateLength.get(formatLength.toLowerCase());
    boolean addCentury = false;
    if ("shortWithCentury".toLowerCase().equals(styleString)) {
        addCentury = true;
    } else {
        style = Integer.parseInt(styleString);
    }

    DateFormat aDateFormat = DateFormat.getDateInstance(style, locale);

    // Cast to SimpleDateFormat to make "toPattern" method available
    SimpleDateFormat format = (SimpleDateFormat) aDateFormat;

    // return the date pattern
    String pattern = format.toPattern();

    if (style == DateFormat.SHORT && addCentury) {
        // hack to add century on generated pattern
        pattern = YEAR_PATTERN.matcher(pattern).replaceAll("yyyy");
    }
    return pattern;
}