Example usage for java.text DateFormat FULL

List of usage examples for java.text DateFormat FULL

Introduction

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

Prototype

int FULL

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

Click Source Link

Document

Constant for full style pattern.

Usage

From source file:lucee.commons.i18n.FormatUtil.java

public static DateFormat[] getDateTimeFormats(Locale locale, TimeZone tz, boolean lenient) {

    String id = "dt-" + locale.hashCode() + "-" + tz.getID() + "-" + lenient;
    DateFormat[] df = formats.get(id);
    if (df == null) {
        List<DateFormat> list = new ArrayList<DateFormat>();
        list.add(DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, locale));
        list.add(DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.LONG, locale));
        list.add(DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.MEDIUM, locale));
        list.add(DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.SHORT, locale));

        list.add(DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.FULL, locale));
        list.add(DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale));
        list.add(DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.MEDIUM, locale));
        list.add(DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT, locale));

        list.add(DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.FULL, locale));
        list.add(DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG, locale));
        list.add(DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, locale));
        list.add(DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, locale));

        list.add(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.FULL, locale));
        list.add(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG, locale));
        list.add(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale));
        list.add(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale));
        add24(list, locale);//from   www.  ja v a  2s . c o m
        addCustom(list, locale, FORMAT_TYPE_DATE_TIME);
        df = list.toArray(new DateFormat[list.size()]);

        for (int i = 0; i < df.length; i++) {
            df[i].setLenient(lenient);
            df[i].setTimeZone(tz);
        }

        formats.put(id, df);
    }

    return df;
}

From source file:Main.java

/**
 * Add a RSS 2.0 Channel Information to a given node - which is your channel node <channel>
 * Note: None of the parameter is supposed to be NULL
 *
 * @param XMLDocument current XML Document
 * @param channelRoot the channel node to which you want the information to be attached to
 * @param title title of your channel/* w  w w.ja  va  2  s. co m*/
 * @param link  link to your channel home
 * @param description description of your channel
 */
public static void addRSSChannelInformation(Document XMLDocument, Node channelRoot, String title, String link,
        String description) {
    // Title node
    Node entry = XMLDocument.createElement("title");
    entry.appendChild(XMLDocument.createTextNode(title));
    channelRoot.appendChild(entry);

    // Link node
    entry = XMLDocument.createElement("link");
    entry.appendChild(XMLDocument.createTextNode(link));
    channelRoot.appendChild(entry);

    // Description node
    entry = XMLDocument.createElement("description");
    entry.appendChild(XMLDocument.createTextNode(description));
    channelRoot.appendChild(entry);

    // lastBuildDate node
    entry = XMLDocument.createElement("lastBuildDate");
    entry.appendChild(XMLDocument.createTextNode(
            DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(new Date())));
    channelRoot.appendChild(entry);

    // language node
    entry = XMLDocument.createElement("language");
    entry.appendChild(XMLDocument.createTextNode("en-gb"));
    channelRoot.appendChild(entry);
}

From source file:DateFormatDemo.java

static public void showBothStyles(Locale currentLocale) {

    Date today;// w w w  . java 2  s  . co  m
    String result;
    DateFormat formatter;

    int[] styles = { DateFormat.DEFAULT, DateFormat.SHORT, DateFormat.MEDIUM, DateFormat.LONG,
            DateFormat.FULL };

    System.out.println();
    System.out.println("Locale: " + currentLocale.toString());
    System.out.println();

    today = new Date();

    for (int k = 0; k < styles.length; k++) {
        formatter = DateFormat.getDateTimeInstance(styles[k], styles[k], currentLocale);
        result = formatter.format(today);
        System.out.println(result);
    }
}

From source file:net.opendasharchive.openarchive.db.MediaDeserializer.java

@Override
public Media deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
        throws JsonParseException {

    Media mediaResult = new Media();

    JsonObject jobj = (JsonObject) json;

    if (jobj.has("mimeType"))
        mediaResult.setMimeType(jobj.get("mimeType").getAsString());

    if (jobj.has("title"))
        mediaResult.setTitle(jobj.get("title").getAsString());

    if (jobj.has("description"))
        mediaResult.setDescription(jobj.get("description").getAsString());

    if (jobj.has("serverUrl"))
        mediaResult.setServerUrl(jobj.get("serverUrl").getAsString());

    if (jobj.has("location"))
        mediaResult.setLocation(jobj.get("location").getAsString());

    if (jobj.has("tags"))
        mediaResult.setTags(jobj.get("tags").getAsString());

    if (jobj.has("licenseUrl"))
        mediaResult.setLicenseUrl(jobj.get("licenseUrl").getAsString());

    if (jobj.has("author"))
        mediaResult.setAuthor(jobj.get("author").getAsString());

    DateFormat ft = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);

    try {//  ww w .  ja  v  a2  s. c  o m
        if (jobj.has("createDate"))
            mediaResult.setCreateDate(ft.parse(jobj.get("createDate").getAsString()));
    } catch (ParseException e) {
        Log.e("MediaDez", "unable to parse date", e);
    }

    try {
        if (jobj.has("updateDate"))
            mediaResult.setUpdateDate(ft.parse(jobj.get("updateDate").getAsString()));
    } catch (ParseException e) {
        Log.e("MediaDez", "unable to parse date", e);
    }

    return mediaResult;
}

From source file:DateFormatDemo.java

static public void showDateStyles(Locale currentLocale) {

    Date today = new Date();
    String result;//from   www  .j  av  a 2 s .c  o m
    DateFormat formatter;

    int[] styles = { DateFormat.DEFAULT, DateFormat.SHORT, DateFormat.MEDIUM, DateFormat.LONG,
            DateFormat.FULL };

    System.out.println();
    System.out.println("Locale: " + currentLocale.toString());
    System.out.println();

    for (int k = 0; k < styles.length; k++) {
        formatter = DateFormat.getDateInstance(styles[k], currentLocale);
        result = formatter.format(today);
        System.out.println(result);
    }
}

From source file:com.google.ie.common.audit.AuditManager.java

/**
 * Add the task to a {@link Queue} to audit the user action.
 * /*from   w ww. j  a  v a 2s .  c om*/
 * @param userKey the key of the user whose action is to be audited
 * @param entityKey the key of the entity on which the action was performed
 * @param action the action performed
 */
public void audit(String userKey, String entityKey, String entityType, String action) {
    /* Use Task Queue to queue the task to audit. */
    Queue queue = QueueFactory.getQueue(IdeaExchangeConstants.TASK_QUEUE);
    TaskOptions taskOptions = TaskOptions.Builder.url(IdeaExchangeConstants.AUDIT_URL)
            .param(IdeaExchangeConstants.USER_KEY, userKey).param(IdeaExchangeConstants.ENTITY_KEY, entityKey)
            .param(IdeaExchangeConstants.ENTITY_TYPE, entityType)
            .param(IdeaExchangeConstants.AUDIT_DATE,
                    DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(new Date()))
            .param(IdeaExchangeConstants.ACTION, action);
    queue.add(taskOptions);
    if (log.isDebugEnabled()) {
        log.debug("Task for auditing added to queue :" + IdeaExchangeConstants.TASK_QUEUE);
    }

}

From source file:DateFormatDemo.java

static public void showTimeStyles(Locale currentLocale) {

    Date today = new Date();
    String result;/*w w w.j  a v  a2  s .c  o  m*/
    DateFormat formatter;

    int[] styles = { DateFormat.DEFAULT, DateFormat.SHORT, DateFormat.MEDIUM, DateFormat.LONG,
            DateFormat.FULL };

    System.out.println();
    System.out.println("Locale: " + currentLocale.toString());
    System.out.println();

    for (int k = 0; k < styles.length; k++) {
        formatter = DateFormat.getTimeInstance(styles[k], currentLocale);
        result = formatter.format(today);
        System.out.println(result);
    }
}

From source file:org.jamwiki.utils.DateUtil.java

/**
 * Given a string, return the matching DateFormat style (SHORT, LONG, etc)
 * or -1 if there is no corresponding style.
 *//* www.j ava 2 s.  c  o  m*/
public static int stringToDateFormatStyle(String format) {
    if (StringUtils.equalsIgnoreCase(format, "SHORT")) {
        return DateFormat.SHORT;
    } else if (StringUtils.equalsIgnoreCase(format, "MEDIUM")) {
        return DateFormat.MEDIUM;
    } else if (StringUtils.equalsIgnoreCase(format, "LONG")) {
        return DateFormat.LONG;
    } else if (StringUtils.equalsIgnoreCase(format, "FULL")) {
        return DateFormat.FULL;
    } else if (StringUtils.equalsIgnoreCase(format, "DEFAULT")) {
        return DateFormat.DEFAULT;
    }
    return -1;
}

From source file:org.openvpms.web.resource.i18n.format.DateFormatter.java

/**
 * Returns the full date format for the current locale.
 * <p/>/*from   w ww .jav  a2  s .  com*/
 * This can be overridden by specifying the <em>date.format.full</em>
 * property in {@code messages.properties}.
 *
 * @return the full date format
 */
public static DateFormat getFullDateFormat() {
    Locale locale = Messages.getLocale();
    if (FULL_DATE_PATTERN != null) {
        return new SimpleDateFormat(FULL_DATE_PATTERN, locale);
    }
    return DateFormat.getDateInstance(DateFormat.FULL, locale);
}

From source file:com.google.ie.web.controller.AuditController.java

/**
 * Register custom binders for Spring. Needed to run on app engine
 * /*from   ww w . j av a  2 s .co  m*/
 * @param binder
 * @param request
 */
@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(Boolean.class, new CustomBooleanEditor(true));
    binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
    binder.registerCustomEditor(Date.class,
            new CustomDateEditor(DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL), true));
}