Thread: Day name

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Location
    Amersfoort, The Netherlands
    Posts
    10
    Rep Power
    0

    Day name


    I need the correct syntax of a java function that returns the name of the day of the given date.


    Can anybody help me?

    Erwin
  2. #2
  3. Golden Member =p
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Location
    Final Frontier
    Posts
    9
    Rep Power
    0
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Location
    Amersfoort, The Netherlands
    Posts
    10
    Rep Power
    0
    Google is my friend too... Still, I need a working example; I'm fed up with the trial & error method. I don't have enough time for that.

    I need something like this:

    Calendar.get(Calendar.DAY_OF_WEEK)

    What the .. is the correct syntax?

    Thanks in advance,

    Erwin
  6. #4
  7. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    String tuesday = new java.text.SimpleDateFormat( "E").format( new java.util.Date().parse( "9-17-2002" ) );
  8. #5
  9. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Bloody hell this thing was annoying. Here ya go.
    Code:
    Date day = ((DateFormat)new java.text.SimpleDateFormat( "MM-dd-yyyy" )).parse( "09-19-2002" );
    String day_name = new java.text.SimpleDateFormat( "EEEEEEEEE" ).format( day );
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Location
    Amersfoort, The Netherlands
    Posts
    10
    Rep Power
    0
    I'll check out the code right away!

    Erwin

    By the way, what did you mean with "Bloody hell this thing was annoying"; the time it took to find the code?
  12. #7
  13. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Ya. SimpleDateFormat extends a class with a parse method that takes a long as a parameter instead of a Date. It took me awhile to track down why I was getting "java.text.SimpleDateFormat.parse( java.util.Date ) not found. long expected" or whatever the error was

    It looked like such a simple thing at first...
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Location
    Amersfoort, The Netherlands
    Posts
    10
    Rep Power
    0
    I understand what you mean; these are the minor irritations during software development. Happily, there are even more goodies to compensate this feeling.. ;-)


    Erwin

IMN logo majestic logo threadwatch logo seochat tools logo