Android Day of Week Calculator
-
Seriously? A
NullPointerException
is being thrown on line 230 becausedate
isnull
. A simple walkthrough with the debugger would have revealed this. :doh:"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
I have initialized Date date = new Date(); but now I get application has stopped working and error is still in the same line!!!
try
{
Date date = new Date();
String getdate = spinner.getItemAtPosition(position).toString() + value
+ textView2.getText().toString();
date = sdf.parse(getdate);
} catch (ParseException ex)
{
// handle parsing exception if date string was different from the pattern applying into the SimpleDateFormat contructor
}
// isDateValid function call
isValid = isDateValid(date.getMonth(), date.getDay(), date.getYear()); -
I have initialized Date date = new Date(); but now I get application has stopped working and error is still in the same line!!!
try
{
Date date = new Date();
String getdate = spinner.getItemAtPosition(position).toString() + value
+ textView2.getText().toString();
date = sdf.parse(getdate);
} catch (ParseException ex)
{
// handle parsing exception if date string was different from the pattern applying into the SimpleDateFormat contructor
}
// isDateValid function call
isValid = isDateValid(date.getMonth(), date.getDay(), date.getYear());Pavlex4 wrote:
I have initialized Date date = new Date();
Which is not the one being passed to
isDateValid()
."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Pavlex4 wrote:
I have initialized Date date = new Date();
Which is not the one being passed to
isDateValid()
."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Maybe look at (or around) line 12.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Maybe look at (or around) line 12.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Correct.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Correct.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
I added date = new Date(); to button onclicklistener but when I click button inside app it gets pressed and stays like that and nothing happens!!!
button.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
String dayOfWeek;
boolean isValid;**date = new Date();** Calendar c = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd\_HHmmss"); String strDate = sdf.format(c.getTime());
-
I added date = new Date(); to button onclicklistener but when I click button inside app it gets pressed and stays like that and nothing happens!!!
button.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
String dayOfWeek;
boolean isValid;**date = new Date();** Calendar c = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd\_HHmmss"); String strDate = sdf.format(c.getTime());
You really need to make more effort to do some debugging of your code first. You have a problem which could be caused by any part of your code, so you need to do the troubleshooting to collect more information. Also you have a try/catch block in your code that reads:
try { String getdate = spinner.getItemAtPosition(position).toString() + value + textView2.getText().toString(); Date date = sdf.parse(getdate); } catch (ParseException ex) { }
Do not do this, you are just hiding any problems that may occur. Put some proper code in the catch block to help you find errors.
-
Can you not see that you have two
Date
objects (in separate scopes)?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Can you not see that you have two
Date
objects (in separate scopes)?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles