Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Help > static field sh...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 15976 of 16069
Post > Topic >>

static field should be accessed in a static way

by ireallyneedtoknow2007@[EMAIL PROTECTED] Apr 15, 2008 at 06:00 PM

Hi
I need to get the current time + 15 minutes for a given time zone.

Question: the c.get(...) show warnings such as
"The static field Calendar.HOUR_OF_DAY should be accessed in a static
way"

how do I avoid these warnings?  thanks

public String addMinutes(String tz)
{
	if (tz.equalsIgnoreCase("E"))tz="US/Eastern";
	else if (tz.equalsIgnoreCase("C")) tz="US/Central";
	else if (tz.equalsIgnoreCase("M")) tz="US/Mountain";
	else if (tz.equalsIgnoreCase("P")) tz="US/Pacific";
	else if (tz.equalsIgnoreCase("A")) tz="US/Alaska";
	else if (tz.equalsIgnoreCase("H")) tz="US/Hawaii";
	DecimalFormat f=new DecimalFormat("00");
	Calendar c = Calendar.getInstance(TimeZone.getTimeZone(tz));
	c.set
	(
		Calendar.getInstance(TimeZone.getTimeZone(tz)).get(Calendar.YEAR),
		Calendar.getInstance(TimeZone.getTimeZone(tz)).get(Calendar.MONTH)
+1 ,
	
Calendar.getInstance(TimeZone.getTimeZone(tz)).get(Calendar.DAY_OF_MONTH),
	
Calendar.getInstance(TimeZone.getTimeZone(tz)).get(Calendar.HOUR_OF_DAY),
		Calendar.getInstance(TimeZone.getTimeZone(tz)).get(Calendar.MINUTE)
	);
	c.add(Calendar.MINUTE,15 );
	// warnings appear below.....
	String t=f.format(c.get(c.YEAR)) +
	f.format(c.get(c.MONTH)) +
	f.format(c.get(c.DAY_OF_MONTH)) +
	f.format(c.get(c.HOUR_OF_DAY)) +
	f.format(c.MINUTE);
	return t;
	}




 4 Posts in Topic:
static field should be accessed in a static way
ireallyneedtoknow2007@[EM  2008-04-15 18:00:32 
Re: static field should be accessed in a static way
Chase Preuninger <chas  2008-04-15 18:08:19 
Re: static field should be accessed in a static way
Roedy Green <see_websi  2008-04-16 03:18:09 
Re: static field should be accessed in a static way
Hendrik Maryns <gtw37b  2008-04-16 11:34:42 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun May 11 18:50:16 CDT 2008.