-
getting the data in java
I'm having trouble finding the function that returns the current date as a
string in a java application. If I can find this out I will then convert
it to an integer and use it in my program, but I need some suggestions on
how to get the date as a string.
Please Help!
-
Re: getting the data in java
Mike,
The current date/time can be found by invoking the
System.currentTimeMillis() method (java.lang.System class). This of course
returns the date in its internal format which is a long. The Java API
separates the internal storage of current date/time from the formatting and
display, which can be accomplished by using the java.text.SimpleDateFormat
class. Use the long obtained from the method invoked above, in conjunction
with the SimpleDateFormat class and you can display a String representation
of date/time, or any part thereof, in about any format you can think of.
Hope that helps.
BradO
----------
Brad O'Hearne
DevX Section Leader
"mike" <m_karpen@hotmail.com> wrote in message news:3d8757cc$1@10.1.10.29...
>
> I'm having trouble finding the function that returns the current date as a
> string in a java application. If I can find this out I will then convert
> it to an integer and use it in my program, but I need some suggestions on
> how to get the date as a string.
> Please Help!
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks