DateFormat based on Locale

Hi,
I have a strange requirement and not sure if it is possible.
I need the date format based on Locale.
Eg: If it is US I need the string "MM/dd/yyyy" as an output and I am not expecting "09/12/2007". I need the string MM/dd/yyyy as an output .
Is there any method I can use?
Thanks

System.out.println("The SHORT format is **" + ((SimpleDateFormat)java.text.DateFormat.getDateInstance(java.text.DateFormat.SHORT, l)).toLocalizedPattern());
System.out.println("The MEDIUM format is **" + ((SimpleDateFormat)java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM, l)).toLocalizedPattern());
System.out.println("The FULL format is **" + ((SimpleDateFormat)java.text.DateFormat.getDateInstance(java.text.DateFormat.FULL, l)).toLocalizedPattern());Gives:
The SHORT format is **M/d/yy
The MEDIUM format is **MMM d, yyyy
The FULL format is **EEEE, MMMM d, yyyy
I guess you should use MEDIUM instead of SHORT

Similar Messages

  • Change error message based on locale

    HI experts,
    I have 2 applicaions .
    one contains task flow containing 1 jsff having one input text required property set to true.
    other contains page template to switch language based on locale.
    now if I put both page template and input text in one application it works fine with error message in appropriate language.
    but if I import task flow into other application as adf jar file and insert TF as region then it gives error message always in english and ok button in appropriate locale.
    can you suggest some solution for this.
    JDEV - 11.4

    These links may use for you get solution
    Localization
    Localization
    Localization Supported Languages
    JDeveloper 11g - Localization Supported Languages
    How to configure code to ResouceBundle in Localization
    Re: How to configure code to ResouceBundle in Localization

  • How to load html file based on locale?

    Based on the browser langugae settings / regional settings (locale), we need to display the one of the html pages.
    html content is specific to country and plain text only not using unicode.
    Is there is a way to load using java. It is working for .propeties file.
    Thanks

    If using jsp/jsf place the text in properties files (according to language again) and then display the text using the bundle.

  • ZipCode validation based on locale

    Hello All.
    I'm currently developing an application and i kind of ran
    into some problems that i'm trying to find a possible solution.
    This app will be used for many users spread out into Europe, Asia
    and Americas and one requirement is to validate a given zipcode
    based on the user's locale.
    I've been trying to find examples on any possible web search
    engine that you could possible think of and no results so far.
    Please, if any examples/questions fell free to write me or
    reply to this topic, your help is greatly appreciated.
    Thanks
    Alvaro Costa
    Software Engineer
    [email protected]

    Here is a macro (sql function) we use for Canadian Postal
    Codes. Bear in mind that the data we receive does not have the
    normal space between the 3rd and 4th characters. The percentage
    sign represents the argument.
    returns Y or N to indicate whether postal code is valid CASE
    WHEN
    SUBSTR(%1,1,1)IN('A','B','C','E','G','H','J','K','L','M','N','P','R','S','T','V','X','Y')A ND
    SUBSTR(%1,2,1)IN('0','1','2','3','4','5','6','7','
    8','9')AND
    SUBSTR(%1,3,1)IN('A','B','C','E','G','H','J','K','L','M','N','P','R','S','T','V','W','X', 'Y','Z')AND
    SUBSTR(%1,4,1)IN('0','1','2','3
    ','4','5','6','7','8','9')AND
    SUBSTR(%1,5,1)IN('A','B','C','E','G','H','J','K','L','M','N','P','R','S','T','V','W','X', 'Y','Z')AND
    SUBSTR(%1,6,
    1)IN('0','1','2','3','4','5','6','7','8','9')THEN 'Y' ELSE
    'N' END

  • Date format based on locale

    Hi Gurus,
    I am currently making changes to some of our existing forms so that the dates and quantities will format properly based on the locale. I am passing in the local to the form and using this to set the format. Everything works fine except for the US dates, which is getting formatted as Jan 21, 2015 instead of 01/21/2015. Because of space constraints I need to use the "shortened" version. I currently have the field set as type Date/Time and nothing listed under Patterns. I tried using date.short{} in the pattern field, but ended up with 01/21/15. Date.medium{} and date.default{} gave me the Jan 21, 2015. Does anyone know if there is a way to get the full 4 digit year?
    Thanks!
    Julie

    Hello Julie
    You can create the following pattern
    date(en_US) {MM/DD/YYYY}
    A default date value must conform to the short format for the locale specified for the date field. However, by default, Designer displays the default value in the medium locale format at both design time and run time.
    For example, consider a form with a Date/Time Field set to use the German (Germany) locale. You enter the default value for a date in the short format DD.MM.YY. After you change the focus to another field, the value specified in the field on the page is displayed in the medium format DD.MM.YYYY. The formatted value also appears in the medium format if you view the form in the Preview PDF tab.
    Note: At run time, by default, form fillers must edit the value of date/time fields using the short format for the locale specified for the field. If you specify an Edit Pattern on the Edit tab in the Patterns dialog box (Field tab > Patterns), that pattern overrides the short format, and users must enter data that conforms to the Edit Pattern.
    Adobe LiveCycle ES3 * Formatting field values and using patterns
    regards
    sandy

  • Changing Look and feel based on locale

    Hi,
    I have following skins in portal project.
    customer_en_US
    customer_en_sp
    customer_en_fr
    Based on logged in user I want specific skin to be applied to the current portal/desktop.
    How can I do it?
    Thanks,
    Kam

    LookAndFeel lookAndFeel
    = LookAndFeel.getLookAndFeel(getRequest());
    lookAndFeel.setSkin("skin1");
    lookAndFeel.reinit();
    Seenu.

  • Snapshot query based on local table...

    Can anyone help me determine the proper syntax for a snapshot query that will pull records based on an previously sync'ed table? In other words I want to get a subset of data into table2 based on what was just sync'ed into table1, where the table1 snapshot contained a where clause with a :parameter.
    I thought the query would look something like this:
    select * from SERVER_SCHEMA.table2
    where
    column1 In (select column1 from &WTG_SCHEMA..table1);
    but I get an error when I try to sync. table1 has a weight of 10 and table2 has a weight of 20.
    TIA,
    Scott

    use the snapshot SQL you used for the first table in the snapshot SQL for the 2nd table.
    ie.
    1st TABLE snapshot
    select * from employees e where e.salary > 1
    2nd table snapshot
    select * from departments d where d.dept_id IN (
    select distinct e.dept_id from employees e where e.salary > 1)
    OR
    select d.*
    from departments d, employees e
    where d.dept_id = e.dept_id
    and e.salary > 1

  • Sort issues in solaris 10 based on Locale settings

    Hi All -
    When Locale is set to en_GB.ISO8859-1 and sort done, the output does not match the sort done on the same file with Locale set to en_US.ISO8859-1. Please note that both are using the ISO8859-1 char set. Why is the difference?
    Your input will greatly help.
    Thanks in advance

    Different locales have different sort orders, the sort order used will be determined by the LC_COLLATE environment variable.
    One example of this is given in the sort manpage;
    If LC_COLLATE  is set to C, sorting will be in ASCII order.
    If LC_COLLATE is set to en_US, sorting is  case  insensitive
    except  when the two strings are otherwise equal and one has
    an uppercase letter earlier than the  other.

  • Icons files will not displaying when running web-based forms locally

    My icon files (jpgs) are not displaying from within Forms Developer 10g or when I run the web-based forms from within Developer. I have tried the following without success:
    6.4 Deploy Icons for Forms Running on Web
    Option One: For Running Web Based Forms from Within the Forms Builder in Oracle 10g Developer Suite
    1) Copy all the icon image files (*.jpg) to the directory of <Oracle_10g_Developer_Suite_Installation_Root_Dir>\forms\j2ee\formsapp\formsweb\icons
    2) Make sure to set imageBase=DocumentBase in the file < Oracle_10g_Developer_Suite_Installation_Root_Dir >\forms\server\formsweb.cfg.
    3) Edit the < Oracle_10g_Developer_Suite_Installation_Root_Dir >\forms\java\oracle\forms\registry\Registry.dat file, specify the icon image file extension by modifying the following line:
    default.icons.iconepath=icons/
    default.icons.iconextension=jpg
    Save this Registry.dat file.
    4) Restart the OC4J Instance.
    5) Launch the form from Forms Builder.
    I just got a new laptop and am setting everything up again. I have everything setup the same way as on my old machine (same as above). It worked fine on my old computer but not on the new one.

    hi
    try to create jar file for u r all jpgs but also u have to check the size of u r images
    and if possible try to resave the same images by using Acdsee or use any other image viewer softwares.
    hope this helps u...
    sarah

  • Formating a phone number based on locale

    How can I format a phone number based on the region setting? E.g. phone numbers will be formated as (xxx) xxx-xxxx if the region is set to US. And formatted otherwise if the region is set to some other country.

    also want to know

  • Date Take Based On Locale

    hi i have developed a one application in this one i have taken today date as current date of Server.But i need a today date taken based on the Todays Date for the users timezone.
    anybody help me please.
    Thanks

    Hi,
    see reply in [How to get Date and Time|How to get Date and Time] thread.
    Romano

  • DateFormat timestamp masks

    I am writing a date generating routine based on the default DateFormat timestamp masks/time pattern Strings. This cycles through different Locales, and gives you the mask for each Locale for short, medium, long, and full format. For an API to an external script, I will need to hash the available Java timestamp masks vs. some predefined masks of my own.
    My question is this. When I review the available Locales' timestamp masks, there are symbols I don't see listed in the documentation for SimpleDateFormat. For example, a.n.j. is one mask that is listed. There is no "j" symbol listed here:
    http://java.sun.com/j2se/1.3/docs/api/java/text/SimpleDateFormat.html
    Does anybody know where I can get a complete list of definitions for these time pattern symbols?
    -Jeff

    Are you using "toLocalizedPattern()" when you print the pattern Strings? toLocalizedPattern() returns the pattern String of DateFormat in a locale specific format... meaning if the locale is set to de.DE (Germany), toPattern will return dd.MM.yy (for SHORT), but toLocalizedPattern will return tt.MM.uu (tag for day and Uhr for year). Could this be what you are seeing?

  • Report locale, subtemplates and Data Model

    Hi,
    I have the following situation:
    We have 4 templates according to language, with french the default language:
    - FR: template.rtf
    - NL: template_nl.rtf
    - DE: template_de.rtf
    - EN: template_en.rtf
    The report locale is enough for BI Publisher to select the correct template, so that's OK.
    Some data from our database is also based on locale (eg street names and cities).
    Question 1: is it possible to use the current locale as parameter for the (sql) data model in some way (eg by using a specific parameter name)? For now we set the report locale to the correct language AND we send that same value through as a parameter. It would be cleaner to just set the report locale and be able to use that value in some way.
    Question 2: all of the above templates have a footer that's being reused, each also share the same data model, but the data is again based on the current locale.
    so: footer.rtf, footer_nl.rtf, footer_de.rtf and footer_en.rtf. Do I need to import all of these in their respective files or will localisation work (I doubt it)?
    Question 3: Is there a way to implicitly pass all parameters that were passed to the main template, also pass to the subtemplates? (eg LANG parameter is passed to template_nl.rtf, who can use it in his data model, is there a way to automatically make LANG available for footer_nl.rtf's data model or do I need to explicitly pass it as a parameter in the <?call-template: footer?>) - again if the report locale is available in some way to the data model, it would be easy.
    Thanks in advance

    Hello,
    Probably the easiest would be to use an OnDemand Process and some AJAX to pull your data into the extjs object.
    Here's an example of an OnDemand Process.
    http://apex.oracle.com/pls/otn/f?p=11933:11
    For data the easiest at the moment would be probably to use the Oracle XML functions to generate your data in XML and use that as your data feed.
    You might want to take a look the new Interactive Reports included in APEX 3.1, while extjs has alot of functions there is a bit of setup involved , while the Interactive Reports all you need is a SQL query http://www.oracle.com/technology/products/database/application_express/html/irrs.html
    You should search the forum for extjs as there has been quite a few successful integrations of APEX and extjs / YUI / jQuery etc.
    Regards,
    Carl
    blog : http://carlback.blogspot.com/
    apex examples : http://apex.oracle.com/pls/otn/f?p=11933:5

  • Regarding error message in a different locale

    Hi
    I have 2 applicaions .
    one contains task flow containing 1 jsff having one input text required property set to true.
    other contains page template having 2 links to switch language based on locale.
    If I use another adf application and import task flow it works well.
    but if I import task flow into webcenter portal application as adf jar file and insert TF as region then it gives error message always in english and ok button in appropriate locale.
    If I use another adf application and import task flow it works well.
    can you suggest some solution for this.
    JDEV - 11.4

    Yes I am using default error messages generated by adf framework . for ex. required="true"
    for changing locale my code is:
      public void setLocaleEnUS() {
        // change the locale
        Locale newLocale = new Locale("en", "US");
        FacesContext fctx=FacesContext.getCurrentInstance();
        fctx.getViewRoot().setLocale(newLocale);
        setPreferredLocale(FacesContext.getCurrentInstance().getViewRoot().getLocale());
      public void setLocaleZhHK() {
        // change the locale
        Locale newLocale = new Locale("zh", "TW");
        FacesContext fctx=FacesContext.getCurrentInstance();
        fctx.getViewRoot().setLocale(newLocale);
        setPreferredLocale(FacesContext.getCurrentInstance().getViewRoot().getLocale());
      }

  • How to manage Locale info in the URL path, but not the query string

    We are building an application using Struts 1.1 and Tiles, on Oracle Application Server 10.1.3.3...
    I know this is a strange question... but we have a requirement to represent the locale info in the URL string using one of the following options:
    option 1: /eng/page.do?id=2 for english.../fra/page.do?id=2
    option 2: /page-eng.do?id=2 for english.... and /page-fra.do?id=2 for french
    We need to represent the 3 letter ISO lang code either in the directory structure, or suffix the page name (in our case, the struts action name)... we cannot replicate this using a parameter in the query string. I know this is odd, but that is what we are told to implement.
    Is there any robust way of implementing either option in Struts 1.1, JSP, JSTL etc...?
    Currently, we are looking at using a servlet filter to intercept the HTTP requests, parse the URL string, and extract the ISO lang value, and set locale and forward on the request.
    This poses a few problems... adding additional action mappings (page-eng... page-fra... page) to our struts-xml.config file to handle lang permuations... but the biggest issue is all the embedded html:link action values throughout our code...
    Because all our public facing URLs must comply with the rule, we need to change the html:link action to point to a different action, based on locale.
    Very inefficent, and I'm sure not industry standard best practice... we are using Tiles, and resource bundles for all our labels etc... but fall short in meeting this rule with regards to URLs and locale.
    Any advice or tips etc.. is greatly appreciated.

    The filter option sounds like a good solution. So it can receive the urls and parse them appropriately.
    You just need to take it one step further.
    Additional actionmappings in your struts-config should not be necessary.
    Filter:
    - analyses the url and sets the appropriate locale
    - adjusts the url such that the next level of the chain does not have to know anything about the locale being encoded in the url string.
    Thus your struts classes and mappings can remain unchanged
    /eng/page.do or /fra/page.do once through the filter should just look like /page.do to struts.
    That should get rid of half of your headache.
    Next the issue of generating urls.
    There are two approaches I can see here
    1 - use the filter approach again, this time with some post processing. Gather the generated HTML in a buffer, and do a find/replace on any urls generated, to put the locale encoding into them.
    2 - Customise struts to produce urls in this format. This would involve the html:link tag, and the html:form tag at the least (maybe others?). Get the source code for struts, and grab the html:link tag code. Extend that class to generate urls as you want them to be generated. I think you would need to extend the class org.apache.struts.taglib.html.LinkTag and override the protected method calculateURL. You would then have to edit/modify the struts-html tld to point the link tag at your classes rather than the standard ones.
    Option 1 is architecturally good because it gives you a well defined layer/border between having the locale encoded in the url, and not having it there. However it involves doing a find/replace on every html going out. This would catch all urls, whether generated by html:link tag or not.
    Option 2 requires customising struts for your own requirements, which may be a bit daunting, but has the advantage of generating the urls correctly without the extra overhead involved with option 1. Of course you would have to ensure that ALL urls are generated with the html:link tag.
    On reflection, I think option 1 is preferable, as both easier and quicker to implement, and doing a better separation in the architecture.
    Cheers,
    evnafets

Maybe you are looking for

  • How can I open two screens of Adobe digital editions at the same time?

    How can I open two screens of Adobe digital editions at the same time?

  • Possible Bug: Business Components and packaging preferences

    I'm using JDev 11g TP2 When I set up package preferences for business components, it is completely ignoring the package I setup for the Entity object. Example: From the menu Tools>Preferences Under the section Business Components>Packages. I set the

  • Downloading from T126 phone to Macbook Pro

    I have a T126 Cruise mobile phone which takes photos.  The manual says to use Join Me to download photos, but the only version of Join Me for Mac that I can find (vintage 2010) does not show the photo or movie files.  Is there a version that does,  a

  • Table Mainenace generator updates problem

    Dear All,   I have created table maintenance generator for custome table,but now while i'm trying to maintain the data from SM30,its not updating my ztable, means: while m trying to change the information and click on save its showing me record saved

  • Help with making part of a picture transparent

    I am very new to Indesign, and I am trying to teach myself how to use it. I was using Microsoft Publisher for my last project, in which I was able to use a transparency tool to click on part of a .gif image to make it transparent, whilst leaving the