Please Help!!!


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Please Help!!!

  1. #1
    Join Date
    Jan 2007
    Posts
    1

    Please Help!!!

    i need to convert any number into hours,minutes, and seconds in java..anyone got some tips/codes that i can use? im confused as ****.

  2. #2
    Join Date
    Mar 2004
    Posts
    78
    You can use java.util.Calendar class.

    Just create an instance, then set your number as time in miliseconds and then read the hour, minute, date, second, milisecond, etc.

    Please read the java doc. The number you supply is 0 based but moment 0 is not the beginning of the epoch and you will have to adjust it accordingly.


    N.B. DO NOT USE ANY TITLE LIKE !!!!!HELP!!!! OR SOMETHING SIMILAR. Just say what is your problem. Also read the notes of the moderator about how to make a decent posting!

    Code in peace!

  3. #3
    Join Date
    Jan 2007
    Posts
    11
    Hope this helps ..

    Calendar calendar = null;
    java.util.Date date = new java.util.Date();
    int day=0,month=0,year=0;
    calendar = Calendar.getInstance();
    calendar.setTime(date);
    day = calendar.get(Calendar.DAY_OF_MONTH);
    month = 1+calendar.get(Calendar.MONTH);
    year = calendar.get(Calendar.YEAR);
    int hour = calendar.get(Calendar.HOUR_OF_DAY);
    int minute = calendar.get(Calendar.MINUTE);

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