Results 1 to 5 of 5
  1. #1
    swati.jyoti is offline Member
    Join Date
    Mar 2009
    Posts
    42
    Rep Power
    0

    Question Locale with SimpleDateFormat

    What does that mean when instantiating a SimpleDateFormat object,specify a locale?

    Its good programming practice..Can u explain with an example..I am not getting the thing...

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    Java Code:
    import java.text.*;
    import java.util.*;
    
    public class LocalDate {
        public static void main(String[] args) {
            String pattern = "hhmm ddMMMyyy";
            Locale[] locales = {
                Locale.CHINA, Locale.CHINESE, Locale.ITALY, Locale.ITALIAN,
                Locale.JAPAN, Locale.JAPANESE
            };
            for(int i = 0; i < locales.length; i++) {
                DateFormat df = new SimpleDateFormat(pattern, locales[i]);
                System.out.printf(" %s: %s%n",
                                   locales[i].getDisplayName(),
                                   df.format(new Date()));
            }
        }
    }

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    I'm not clear what you exactly talking about here. Seems to me is the following.

    SimpleDateFormat class have a constructor as follows.

    Java Code:
    SimpleDateFormat(String pattern, Locale locale)
    So I guess you have mess-up with Local object. Did you read the Java doc related to that? Here Locale object represent a specific geographical location. You can find around 20 Local fields in the Java doc, sorry I didn't remember exact figures here.

    Is that what you are looking for?

  4. #4
    swati.jyoti is offline Member
    Join Date
    Mar 2009
    Posts
    42
    Rep Power
    0

    Default

    :) Ya this was the same thing i m looking for...

    Thanks...

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. How to use SimpleDateFormat in J2ME Applications
    By thirupathik in forum CDC and Personal Profile
    Replies: 9
    Last Post: 08-13-2010, 08:18 PM
  2. Using SimpleDateFormat
    By Java Tip in forum Java Tip
    Replies: 1
    Last Post: 07-18-2008, 08:33 AM
  3. Locale example
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-29-2008, 09:04 AM
  4. How ro change the locale of JVM
    By ravi.ks007@hotmail.com in forum Advanced Java
    Replies: 2
    Last Post: 12-26-2007, 06:17 AM
  5. Locale
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-16-2007, 02:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •