-
March 16th, 2005, 05:11 AM
#1
Format like function
Hi,
I was wondering if java supports a Format function like VB.
Or do I need to program this myself?
Thx,
Jewe
A VB programmer trying to stay alive in a Real C World
If the hardware is so great.. why use software to correct it..?? It will only slow it down..
Al is de hardware nog zo snel de software achterhaalt het wel
-
March 17th, 2005, 06:25 AM
#2
Re: Format like function
Can u explain this function? Most of us here dont know VB.
Kalyan Chakravarthy C.P.S
"The difference between the possible and the impossible lies in a person's determination and patience."
-
March 17th, 2005, 06:37 AM
#3
Re: Format like function
ok,
with format you can specify the way a string is defined.
for example:
Format(Now,"YYYY-MM-DD") returns "2005-03-17"
but also mlCount ( a long == int in java)
Format(mlCount ,"0000") -->
mlCount = 1 --> 0001
mlCount = 34532 --> 34532
Ik know in C you use printf functions for this but what is the defined way in Java?
thx,
Jewe
(Java wannabe)
A VB programmer trying to stay alive in a Real C World
If the hardware is so great.. why use software to correct it..?? It will only slow it down..
Al is de hardware nog zo snel de software achterhaalt het wel
-
March 17th, 2005, 07:56 AM
#4
Re: Format like function
Hi,
I'm not aware of any one function that can handle Dates and Numbers. However there is a NumberFormat class, with associated SubClasses, that handle formatting Numbers. For dates have a look at SimpleDateFormat.
Why does a long equal an int in java?
Regards
Byron
-
March 17th, 2005, 10:22 AM
#5
Re: Format like function
Java 1.5 introduced a C-like printf() method which emulates C's printf to output formatted strings (I would post the appropriate api page for printf, but Sun's website seems to be loading incredibly slowly for me).
Hungarian notation, reinterpreted? http://www.joelonsoftware.com/articles/Wrong.html
-
March 17th, 2005, 10:46 AM
#6
Re: Format like function
Originally Posted by Bnt
Why does a long equal an int in java?
Sorry my mistake should be Long in vb = int in Java.
A VB programmer trying to stay alive in a Real C World
If the hardware is so great.. why use software to correct it..?? It will only slow it down..
Al is de hardware nog zo snel de software achterhaalt het wel
-
March 18th, 2005, 06:43 AM
#7
Re: Format like function
for formatting dates, use SimpleDateFormat
for formatting numbers, use a subclass of java.text.Format -> http://www.particle.kth.se/~lindsey/...malFormat.html
or use java.util.Formatter (1.5 only?)
in java 1.5, if your sole concren is printing numbers to the console, the System.out.printf() method uses C-like syntax, in combination with the Formatter class mentioned above to produce the output
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|