getting the data in java


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: getting the data in java

  1. #1
    mike Guest

    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!

  2. #2
    Brad O'Hearne Guest

    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center