Results 1 to 7 of 7
  1. #1
    rbercovi is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Cool How to create a Date feature in Java?

    Hey everyone, i'm new to Java and no nothing really just basic concepts in editing and stuff if I would have a code... but I'm looking for a simple code

    just a date function

    so it displays todays date for everyday, and the option for me to change the font size, colour and style?

    much appreciated!!

    thanks!

  2. #2
    StormyWaters is offline Senior Member
    Join Date
    Feb 2009
    Posts
    307
    Rep Power
    6

    Default

    Question,

    How do you plan on displaying the date? Is it going to be part of a GUI or are you printing it somewhere?

    I would suggest first making a method that returns the date. To help, look at this class

    Calendar (Java 2 Platform SE 5.0)

  3. #3
    rbercovi is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Default

    well I just want it to display on the top left of my site. Here is the code I already have:

    <script language = "JavaScript">


    var now = new Date();
    var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thu rsday","Friday","Saturday");
    var monNames = new Array("January","February","March","April","May"," June","July","August","September","October","Novem ber","December");
    document.write("Today's date is " + dayNames[now.getDay()] + " " + monNames[now.getMonth()] + " " + now.getDate() + ", " + now.getFullYear());

    </script>



    It works, its just that I can't figure out how to change the font style, size and colour of it...

  4. #4
    StormyWaters is offline Senior Member
    Join Date
    Feb 2009
    Posts
    307
    Rep Power
    6

    Default

    Ohhh, you're talking about JavaScript not Java, those are two different things...

    Sorry, I'm unfortunately not going to be able to help you, but hopefully someone else knows a little bit of JavaScript.

  5. #5
    rbercovi is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Default

    maybe you know a way to display the date in Java? where I can change the font size and colour? or it's only done through scripts?

  6. #6
    StormyWaters is offline Senior Member
    Join Date
    Feb 2009
    Posts
    307
    Rep Power
    6

    Default

    w3schools can be your friend lol

    Check out this link, Maybe it can help you

    Tryit Editor v1.4

    I would just substitute your date in where the data is.

  7. #7
    rbercovi is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

Similar Threads

  1. java.util.Date vs java.sql.Date
    By Jack in forum New To Java
    Replies: 5
    Last Post: 10-28-2010, 03:59 PM
  2. Replies: 8
    Last Post: 12-17-2009, 12:37 PM
  3. Compare date input to database with current date
    By hungleon88 in forum Advanced Java
    Replies: 2
    Last Post: 11-25-2008, 09:10 AM
  4. java: zoom type feature??
    By newtojava7 in forum Advanced Java
    Replies: 1
    Last Post: 04-02-2008, 06:15 PM
  5. Replies: 1
    Last Post: 02-04-2008, 09:26 PM

Posting Permissions

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