File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt in DateFormat & NumberFormat class

 
Srividhya Kiran
Ranch Hand
Posts: 166
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Can someone explain me what does this mean with an example. Its given in K & B page no 468 exam watch

Both DateFormat and Number Format objects can have their locales set only at the time of instantiation. Watch for code that attempts to change the locale of an existing instance.

Thanks
Srividhya
 
manny singh
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means there are no setters for both once instansciated!!

as i understand?

Locale locin = new Locale("hi","IN");
Locale locit = new Locale("it","IT");
DateFormat df=DateFormat.getDateInstance(DateFormat.FULL,locin);

//what would you do to change locale above to locit??
[ April 04, 2008: Message edited by: manny singh ]
 
Srividhya Kiran
Ranch Hand
Posts: 166
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello manny

I cant get you. Can you please explain it to me.
Thanks
Srividhya
 
Bob Ruth
Ranch Hand
Posts: 320
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It might help to think of it in this way: the only way to set the Locale in one of those objects is with the constructor. Thus, the only way that you can set the Locale is to instantiate a new one. There is no setLocale() method or any other means of changing an object's locale. So if you must change locale, you must instantiate a new object.
 
Sandeep Bhandari
Ranch Hand
Posts: 201
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or the point being emphasized is like the question in exam is written to fool you like

d.setLocale("en","US"); //this is wrong (compiler error)
 
Srividhya Kiran
Ranch Hand
Posts: 166
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for everyone I got it....
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic