Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7720703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:44:21+00:00 2026-06-01T03:44:21+00:00

i want to display the current date in this format Wednesday march 28,2012 ,

  • 0

i want to display the current date in this format Wednesday march 28,2012 , i wrote a method to get this format but it gives invalid values of the date (since when i run the code it gives Saturday sep2,1933) why is that ? what is the error in my code?

this is my code:

public class AddExercise extends Activity
 {   
   private Date   exercise_date;
   private TextView   date_Txt;
   Calendar localCalendar = Calendar.getInstance();
   public void onCreate(Bundle savedInstanceState) 
  {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.add_exercise);

    int  year = localCalendar.get(Calendar.YEAR);
    int  month = localCalendar.get(Calendar.MONTH);
    int day = localCalendar.get(Calendar.DAY_OF_MONTH);
    exercise_date = new Date(day, month , yr);
    date_Txt=(TextView)findViewById(R.id.date);
    String  x=formatdate(exercise_date, "EEEE MMM d, yyyy");
    date_Txt.setText(x);
        }

        public static String formatdate(Date paramDate, String paramString)
  {
    String str;
    if (paramDate != null)
    {
      if (paramString == null)
        paramString = "MMMM dd, yyyy";
      str = new SimpleDateFormat(paramString).format(paramDate);
    }
    else
    {
      str = null;
    }
    return str;
  }     
     }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:44:23+00:00Added an answer on June 1, 2026 at 3:44 am

    This is primarily because you are using deprecated Date() constructor.
    It requires following Parameters:
    year – the year minus 1900.
    month – the month between 0-11.
    date – the day of the month between 1-31.
    But you are passing incorrect year altogether

    Why don’t you simply do this:

    return new SimpleDateFormat("MMMM dd,yyyy").format(localCalendar.getTime())
    

    or better yet

    return new SimpleDateFormat("MMMM dd,yyyy").format(new Date()));
    

    Instead of jumping through all the hoops?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want Perl to display current date and time in the following format: 2010-02-11
Say the current date is 1st Mar 2010, I want to display it like
I want to have a simple app that display the current date. Say for
I have this simple Java Script code to display the date. I want to
Hi I want to display player position and player duration in simple date format.
I want to display the current host and database names in a view. Where
I want to display tabular type data, but it will not be coming from
I want to display dates in the format: short day of week, short month,
I want to display a thumbnail image in a cell of tableViewController , this
I have a Microsoft SQL 2005, reporting project. I want to display the Current

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.