Example usage for java.text DateFormat LONG

List of usage examples for java.text DateFormat LONG

Introduction

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

Prototype

int LONG

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

Click Source Link

Document

Constant for long style pattern.

Usage

From source file:org.exoplatform.answer.webui.FAQUtils.java

public static String getLongDateFormat(Date myDate) {
    return getFormatDate(DateFormat.LONG, myDate);
}

From source file:be.fedict.eidviewer.gui.printing.IDPrintout.java

private void initI18N() {
    Locale.setDefault(ViewerPrefs.getLocale());
    bundle = ResourceBundle.getBundle("be/fedict/eidviewer/gui/resources/IDPrintout");
    dateFormat = DateFormat.getDateInstance(DateFormat.LONG, Locale.getDefault());
    coatOfArms = ImageUtilities.getImage(IDPrintout.class, ICONS + bundle.getString("coatOfArms"));
}

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;//  ww  w  .  j a  va2s  .  c o  m
}

From source file:no.abmu.abmstatistikk.annualstatistic.service.hibernate2.AnnualStatisticServiceHelper.java

private void timeStampReport(Map<String, Object> report) {
    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.MEDIUM,
            LocaleTypeNameConst.BOKMAAL);

    report.put("timestamp", dateFormat.format(new Date()));
}

From source file:net.sourceforge.vulcan.core.support.AbstractProjectDomBuilder.java

private void addTimestampNode(final Element parent, String nodeName, final Date date, final DateFormat format,
        Locale locale) {//from   w ww.ja va  2 s.  c  om
    if (date != null) {
        final DateFormat textualDateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT,
                locale);

        final Element timestampNode = addChildNodeWithText(parent, nodeName, format.format(date));
        timestampNode.setAttribute("millis", Long.toString(date.getTime()));
        timestampNode.setAttribute("text", textualDateFormat.format(date));
    }
}

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;
    }/*ww  w .j a  va2 s .c om*/

    return DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.FULL).format(new Date(nextRotation));
}

From source file:org.exoplatform.faq.webui.FAQUtils.java

private static String getFormatDate(int dateFormat, Date myDate) {
    if (myDate == null)
        return "";
    String format = (dateFormat == DateFormat.LONG) ? "DDD,MMM dd,yyyy" : "MM/dd/yyyy";
    try {/*from   www . j  a v  a  2s . c  o  m*/
        String userName = getCurrentUser();
        if (!isFieldEmpty(userName)) {
            org.exoplatform.forum.service.ForumService forumService = (org.exoplatform.forum.service.ForumService) ExoContainerContext
                    .getCurrentContainer()
                    .getComponentInstanceOfType(org.exoplatform.forum.service.ForumService.class);
            org.exoplatform.forum.service.UserProfile profile = forumService.getUserSettingProfile(userName);
            format = (dateFormat == DateFormat.LONG) ? profile.getLongDateFormat()
                    : profile.getShortDateFormat();
        }
    } catch (Exception e) {
        log.debug("No forum settings found for date format. Will use format " + format);
    }
    if (!isFieldEmpty(format)) {
        if (format.indexOf("DDDD") >= 0)
            format = format.replaceAll("DDDD", "EEEE");
        if (format.indexOf("DDD") >= 0)
            format = format.replaceAll("DDD", "EEE");
    }
    PortalRequestContext portalContext = Util.getPortalRequestContext();
    Format formatter = new SimpleDateFormat(format, portalContext.getLocale());
    return formatter.format(myDate);
}

From source file:com.concursive.connect.web.portal.PortalUtils.java

public static void populateObject(Object bean, ActionRequest request) {
    String nestedAttribute = "_";

    Enumeration en = request.getParameterNames();
    String paramName = null;//from  w w w  .j a  v  a  2 s  .  c  o  m
    while (en.hasMoreElements()) {
        paramName = (String) en.nextElement();

        // a form has been submitted and requested to be auto-populated,
        // so we do that here..going through every element and trying
        // to call a setXXX() method on the bean object passed in for the value
        // of the request parameter currently being checked.
        String[] paramValues = request.getParameterValues(paramName);
        if (paramValues.length > 1) {
            ObjectUtils.setParam(bean, paramName, paramValues, nestedAttribute);
        } else {
            ObjectUtils.setParam(bean, paramName, paramValues[0], nestedAttribute);
        }
    }

    // TODO: currently for ticket and ticket history
    //ObjectUtils.invokeMethod(bean, "setRequestItems", new HttpRequestContext(request));
    // Check for valid user
    User thisUser = (User) request.getAttribute(Constants.REQUEST_USER);
    if (thisUser != null) {
        // Populate date/time fields using the user's timezone and locale
        if (thisUser.getTimeZone() != null) {
            ArrayList timeParams = (ArrayList) ObjectUtils.getObject(bean, "TimeZoneParams");
            if (timeParams != null) {
                Calendar cal = Calendar.getInstance();
                Iterator i = timeParams.iterator();
                while (i.hasNext()) {
                    // The property that can be set
                    String name = (String) i.next();
                    // See if it is in the request
                    String value = request.getParameter(name);
                    if (value != null) {
                        // See if time is in request too
                        String hourValue = request.getParameter(name + "Hour");
                        if (hourValue == null) {
                            // Date fields: 1-1 mapping between HTML field and Java property
                            ObjectUtils.setParam(bean, name,
                                    DateUtils.getUserToServerDateTimeString(
                                            TimeZone.getTimeZone(thisUser.getTimeZone()), DateFormat.SHORT,
                                            DateFormat.LONG, value, thisUser.getLocale()));
                        } else {
                            // Date & Time fields: 4-1 mapping between HTML fields and Java property
                            try {
                                Timestamp timestamp = DatabaseUtils.parseDateToTimestamp(value,
                                        thisUser.getLocale());
                                cal.setTimeInMillis(timestamp.getTime());
                                int hour = Integer.parseInt(hourValue);
                                int minute = Integer.parseInt(request.getParameter(name + "Minute"));
                                String ampmString = request.getParameter(name + "AMPM");
                                if (ampmString != null) {
                                    int ampm = Integer.parseInt(ampmString);
                                    if (ampm == Calendar.AM) {
                                        if (hour == 12) {
                                            hour = 0;
                                        }
                                    } else {
                                        if (hour < 12) {
                                            hour += 12;
                                        }
                                    }
                                }
                                cal.set(Calendar.HOUR_OF_DAY, hour);
                                cal.set(Calendar.MINUTE, minute);
                                cal.setTimeZone(TimeZone.getTimeZone(thisUser.getTimeZone()));
                                ObjectUtils.setParam(bean, name, new Timestamp(cal.getTimeInMillis()));
                            } catch (Exception dateE) {
                            }
                        }
                    }
                }
            }
        }

        // Populate number fields using the user's locale
        if (thisUser.getLocale() != null) {
            ArrayList numberParams = (ArrayList) ObjectUtils.getObject(bean, "NumberParams");
            if (numberParams != null) {
                NumberFormat nf = NumberFormat.getInstance(thisUser.getLocale());
                Iterator i = numberParams.iterator();
                while (i.hasNext()) {
                    // The property that can be set
                    String name = (String) i.next();
                    // See if it is in the request
                    String value = (String) request.getParameter(name);
                    if (value != null && !"".equals(value)) {
                        try {
                            // Parse the value
                            ObjectUtils.setParam(bean, name, nf.parse(value).doubleValue());
                        } catch (Exception e) {
                            //e.printStackTrace(System.out);
                        }
                    }
                }
            }
        }
    }
}

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.//  w  ww .  j  a v  a 2s . c o m
 */
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;
}