Hi,
I was wondering if java supports a Format function like VB.
Or do I need to program this myself?
Thx,
Jewe
Printable View
Hi,
I was wondering if java supports a Format function like VB.
Or do I need to program this myself?
Thx,
Jewe
Can u explain this function? Most of us here dont know VB.Quote:
Format function like VB.
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)
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?Quote:
( a long == int in java)
Regards
Byron
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).
Sorry my mistake should be Long in vb = int in Java.Quote:
Originally Posted by Bnt
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