×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    May 2013
    Posts
    280

    How to get day of week name and month name for any pevious date(not current date)

    I have some dates starting from 12-04-2004 to current date. How can i find day of week and month name on selected date from date picker.

    I am getting dates in following format from datepicker : date/month/year. (It is easy for me to pick date and year directly from picker by substring method). How to get day of week and month since for month i need to display like October(i can solve month part with if else statements too but stuck on day of week part)?..

    Plz help.

    Also i need to display the date in big font size on upper left of UI. i will substring the date format and take date. But how can i increase the sizeof label. should i use setPreffered width and height methods?
    Last edited by Manpreet_Singh; 2013-09-05 at 07:07.

  2. #2
    Regular Contributor
    Join Date
    Dec 2012
    Location
    India
    Posts
    271

    Re: How to get day of week name and month name for any pevious date(not current date

    I dont think there is a direct function available to retrieve that information unfortunately.However, googling about it gave me a few interesting links, which could be programmed.

    http://www.wikihow.com/Know-the-Day-...ay-of-Any-Year
    http://easycalculation.com/funny/shortcuts/day.php

  3. #3
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: How to get day of week name and month name for any pevious date(not current date

    Quote Originally Posted by Manpreet_Singh View Post
    I have some dates starting from 12-04-2004 to current date. How can i find day of week and month name on selected date from date picker.

    I am getting dates in following format from datepicker : date/month/year. (It is easy for me to pick date and year directly from picker by substring method). How to get day of week and month since for month i need to display like October(i can solve month part with if else statements too but stuck on day of week part)?..

    Plz help.

    Also i need to display the date in big font size on upper left of UI. i will substring the date format and take date. But how can i increase the sizeof label. should i use setPreffered width and height methods?
    Which date-picker component you are using - both J2me and LWUIT dateField or DatePicker gives us direct methods to get all 3 values.
    For converting numbers in to Name of day or Name of month - you can have String array of Name of months /days directly maping them to numeric day or month no. that you get from date picker.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  4. #4
    Registered User
    Join Date
    May 2013
    Posts
    280

    Re: How to get day of week name and month name for any pevious date(not current date

    arunkam..well that trick is awsummmmm @im2amit... i m using lwuit form and calender class

  5. #5
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: How to get day of week name and month name for any pevious date(not current date

    Quote Originally Posted by Manpreet_Singh View Post
    arunkam..well that trick is awsummmmm @im2amit... i m using lwuit form and calender class
    With LWUIT Calender - you can get selected data - java.util.date Object.

    public java.util.Date getDate() method of com.sun.lwuit.Calendar class
    Returns:
    the date object matching the current selection


    Now use toString() of java.util.Date class it will Return
    Converts this Date object to a String of the form:
    dow mon dd hh:mm:ss zzz yyyy

    use simple sub-string operations to get dow - day of week and mon Month name.
    toString

    public String toString()
    Converts this Date object to a String of the form:
    dow mon dd hh:mm:ss zzz yyyy
    where:
    dow is the day of the week (Sun, Mon, Tue, Wed, Thu, Fri, Sat).
    mon is the month (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec).
    dd is the day of the month (01 through 31), as two decimal digits.
    hh is the hour of the day (00 through 23), as two decimal digits.
    mm is the minute within the hour (00 through 59), as two decimal digits.
    ss is the second within the minute (00 through 61, as two decimal digits.
    zzz is the time zone (and may reflect daylight savings time). If time zone information is not available, then zzz is empty - that is, it consists of no characters at all.
    yyyy is the year, as four decimal digits.
    Last edited by im2amit; 2013-09-05 at 14:46.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  6. #6
    Registered User
    Join Date
    May 2013
    Posts
    280

    Re: How to get day of week name and month name for any pevious date(not current date

    Thanks , is there a way to get this by using date class and calendar class of java.util package? i mean i am selecting date from spinner component of lwuit

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: How to get day of week name and month name for any pevious date(not current date

    Are you reading this discussion too, or just posting questions into it? Amit clearly describes that everything in #5 is about java.util.Date.toString().

  8. #8
    Registered User
    Join Date
    May 2013
    Posts
    280

    Re: How to get day of week name and month name for any pevious date(not current date

    ok.....i was getting confused between lwuit calender class(which opens calendar to select date) and java.util calendar.
    Last edited by Manpreet_Singh; 2013-09-12 at 05:07.

  9. #9
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: How to get day of week name and month name for any pevious date(not current date

    Quote Originally Posted by Manpreet_Singh View Post
    Thanks , is there a way to get this by using date class and calendar class of java.util package? i mean i am selecting date from spinner component of lwuit
    Yes - Lwuit Calendar class gives java.util.Date using getDate() method

    Then if you have java.util.Date Object you can use toString for it and read using sub-string method.

    http://docs.oracle.com/javame/config...idp2.0/jsr118/
    This class has been subset for the J2ME based on the JDK 1.3 Date class. Many methods and variables have been pruned, and other methods simplified, in an effort to reduce the size of this class.
    So we cannot use - things like getDay(), getHours() here as these are depreciated.
    http://docs.oracle.com/javase/1.4.2/...util/Date.html
    Last edited by im2amit; 2013-09-12 at 06:23.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  10. #10
    Regular Contributor
    Join Date
    Dec 2012
    Location
    India
    Posts
    271

    Re: How to get day of week name and month name for any pevious date(not current date

    Great! Never knew it was so simple. Been doing it the hard way all along! Thanks @im2amit

    Cheers!

Similar Threads

  1. getting current date
    By vinayakak in forum Symbian
    Replies: 5
    Last Post: 2010-03-03, 12:26
  2. Current Date
    By NightStalkerDNS in forum Mobile Java General
    Replies: 2
    Last Post: 2010-01-02, 12:39
  3. how to get current date ?
    By nokia_lin in forum Symbian
    Replies: 5
    Last Post: 2009-04-22, 11:31
  4. Retrieving the day,month and year from the Date Editor
    By joteddy123 in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 3
    Last Post: 2009-03-26, 22:52
  5. current date? today's date?
    By mango7 in forum Symbian
    Replies: 3
    Last Post: 2008-10-30, 06:45

Posting Permissions

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