Thread: Displaying time in a Java format.

Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1 Displaying time in a Java format. 




    Scu11's Avatar
    Join Date
    Aug 2007
    Age
    27
    Posts
    16,206
    Thanks given
    7,190
    Thanks received
    12,171
    Rep Power
    5000
    Difficulty: 1/10
    Purpose: To teach you how to display time in Java formats.
    Reason: To show the time?

    Result:

    Procedure:


    Step 1. Make sure you have the following at the top of your Java document.
    Code:
    import java.io.*;
    import java.util.*;
    import java.util.StringTokenizer;
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    import java.text.*;
    import java.security.*;
    What do they do?:

    Those imports are what initiates Java into your document. There are many Java imports, as you can see, util.Calendar is what brings your computers calendar into Java.

    Why do we need them?:

    Because we are using Java, so we need the Java parts, otherwise it wouldn't make sense or do anything.

    Step 2.

    Using the time.

    Now that we have imported Java, we need to use it. This will make it work properly. Find any void that is called by update();, for this I'm going to use writePlayers();

    Step 3.

    Implementing the time into a void.

    First of all, we need to make the said void know what we are doing. Add these 2 lines at the top of your void.
    Code:
    SimpleDateFormat sdf = new SimpleDateFormat("h:mm:ss a");
    String date = sdf.format(new Date());
    What are they?:

    The first line is an object, followed by a new instance being created of this object. The string is what our void is going to use to get the time. Every time the string "date" is called, it will update the "Date" using the SimpleDateFormat.

    Why do we need them?:

    To make our void know what terms we are on about.

    Step 4.

    Sending the time.

    As shown in the picture, at the top of my screen is the time. Now you can move this to anywhere you like, but for easiness I will give you the frames in the picture. So in your void, add
    Code:
    sendFrame126("@[email protected]                   "+ date, 6570);
    sendFrame126("@[email protected] Static-Pkz", 6572);
    sendFrame126("@[email protected]: "+PlayerHandler.getPlayerCount()+"", 6664);
    setInterfaceWalkable(6673);
    What does this do?:

    This sends the time through a frame.

    Why do we need this?:

    To show the time at the top of the screen.


    I hope you enjoyed this simple tutorial, I have tried my best to explain it and make you learn something. Any suggestions for improving this topic are welcome, and remember, if you can't say soemthing nice, don't say anything at all. Thanks.
    Last edited by Josh; 05-16-2011 at 04:20 PM.

    [Only registered and activated users can see links. ]



     

  2. #2  
    I'm unique


    Join Date
    Oct 2006
    Age
    29
    Posts
    708
    Thanks given
    0
    Thanks received
    1
    Rep Power
    82
    A great explained tutorial Good work with this one. Reputation added
    Sincerly yours,
    Simox.
     

  3. #3  
    × Se×pert ×
    Guest
    Uh ... Nice? I posted this 4x before on Rune-Server help topics , In my Announcement GUI and in my Report abuse tut...
     

  4. #4  




    Scu11's Avatar
    Join Date
    Aug 2007
    Age
    27
    Posts
    16,206
    Thanks given
    7,190
    Thanks received
    12,171
    Rep Power
    5000
    Thanks alot Simox, Sexpert, thats in help topics, it hasn't got a tpoic of its own, so don't flame me. thx

    [Only registered and activated users can see links. ]



     

  5. #5  
    Fallen Azn SinZ
    Guest
    It looks like you don't really have a full understanding when you were explaining the Java imports, and what they did.

    But it is pretty well explained anyway.
     

  6. #6  
    Registered Member
    Join Date
    Feb 2007
    Posts
    308
    Thanks given
    0
    Thanks received
    1
    Rep Power
    72
    Almost all of what you said was wrong.
    The first line is an int, called upon by the second, a string.
    The first line is an Object, not an int.
    [Only registered and activated users can see links. ] - The ultimate source of technical RuneScape information.
     

  7. #7  
    Fallen Azn SinZ
    Guest
    I realised that about 3 seconds after I posted .
    When you posted:

    ...by using the SimpleDateFormat sdf.

    Take out the sdf. Unless you want to explain what it is. If I can remember correctly,
    when you say:

    SimpleDateFormat sdf = new SimpleDateFormat

    the sdf can be anything really, and when you put the new in it's creating a new instance of the SimpleDateFormat.

    Correct me if I'm wrong, but I'll re-read up on the new statement later tonight.

    I realised that about 3 seconds after I posted .

    I don't really think this person knows what they're talking about.


    When you posted:

    ...by using the SimpleDateFormat sdf.
    You just need to say:

    ...by using the SimpleDateFormat.
    And change the void words to methods.



    The first line is an Object, not an int.

    should be:

    The first line is an object, followed by a new instance being created of this object.
    (If that's correct)
    Correct me if I'm wrong samuraiblood2
    Last edited by Fallen Azn SinZ; 12-27-2007 at 10:03 AM. Reason: Double posting is not allowed!
     

  8. #8  
    Registered Member
    Join Date
    Feb 2007
    Posts
    308
    Thanks given
    0
    Thanks received
    1
    Rep Power
    72
    @Fallen: Wow, everything you said was right! I'm officially impressed .
    [Only registered and activated users can see links. ] - The ultimate source of technical RuneScape information.
     

  9. #9  
    Fallen Azn SinZ
    Guest
    Really Samurai? Awewsome I'm making a tut about 3D Java Game Development at the moment.
     

  10. #10  
    freakshow
    Guest
    Is there anyway to make it count down for a restarter?
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •