This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
When displaying the time in a clock,if i want the numbers displayed as roman literals like I,II,III,IV..What should i do.is there any available API which takes the numbers and returns the roman literals corresponding to them?
If you only need values for the numbers 1-12, I think it would be pretty easy to just make an array with 12 different strings for the 12 different values you need to convert.
Then you can just look up values from the array, yes?
One issue to beware of here is that the "first" elemnt of this array is element 0, which maps to "I", and the "second" is element 1, which maps to "II". So you will need to do something to fix this minor off-by-one error...
"I'm not back." - Bill Harding, Twister
Joined: Jun 18, 2006
Thanks for the replies..Perhaps there is no place like javaranch where we can find answers so quickly..
Now, i have one more question. What if i want to use other languages like german and languages which have different character set like hindi etc. How should i proceed..i know that java supports all character sets because of UNICODE support, but dont know how to print characters in other character sets .
Now you're asking a very different question. The question of using a German or other character set has nothing to do with Roman numerals. You can indeed use Java to show characters of any character set, as long as the required font is installed. E.g., something line Microsofts MS Arial Unicode font may be required to view Hindi, Chinese, Japanese or Korean characters. But be aware trhat many consoles can't handle Unicode, so System.out.println may not produce the results you expect.
Joined: Jun 18, 2006
Yes, i did ask complete different question and thanks for the answer. But can you be more clear. I mean what API i have to use?. Is it just that i select the font installed in the system and use it?
Joined: Mar 22, 2005
You don't have to use any API - Java has all necessary capabilities built in. The important question is: where do you want Unicode characters to be displayed? Like I said, most consoles can't handle anything but ASCII, or maybe ISO-8859-1 if you're lucky, but not Hindi etc.
Web browsers can display those characters as long as you set the proper encoding (Content-Type should be "text/html; charset=utf-8") and an appropriate font is installed. Check this page to see which fonts you have. [ July 06, 2006: Message edited by: Ulf Dittmer ]
Joined: Jan 30, 2000
Aside from console output or a web application viewable from a browser, the other main option you may have is to build a GUI application using Swing/AWT or SWT. As a quick & simple option, you could do something like this:
Many more elaborate & complex applications are possible. If console output is good enough, that's easiest. If you want to print German on computers running in Germany, that will probably work fine. If the computer is in China, maybe not - it's probably set up differently. Otherwise you probably need to decide whether you want a web application or a GUI. Either option will require you to learn some additional technology.