BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 02-17-2010, 01:23 AM   #1 (permalink)
New Member
 
Join Date: Feb 2010
Model: 7600
PIN: N/A
Carrier: ATT
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Date time problem

Please Login to Remove!

Hello everyone

Im working on a clock type of app. And im totally new to java .
On the main screen i want to have the current time and i cant seem to get it to show up, could some one help me out?

public static void main (String[] args)
{

Clock app = new Clock();
app.enterEventDispatcher();
}
public Clock()
{
pushScreen(new ClockScreen());
}

}
final class ClockScreen extends MainScreen
{
public ClockScreen()
{
//super();
LabelField t = new LabelField("Current Time is",
LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle(t);

}
public static String StringToDate(String dateToParse)
{
Date formatter = new Date(HttpDateParser.parse(dateToParse));
SimpleDateFormat dateFormat = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss.SSS");
int offset = TimeZone.getDefault().getRawOffset();
formatter.setTime(formatter.getTime() + offset);
String customd = dateFormat.format(formatter);
return customd;
}

when i am returning customd, im expecting to see something.
what would i need to add to this code anyone?

thanx in advance
Offline  
Old 02-17-2010, 08:36 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

I don't see where your StringToDate is ever called, or where the value is ever displayed.
Offline  
Old 02-17-2010, 10:26 AM   #3 (permalink)
New Member
 
Join Date: Feb 2010
Model: 7600
PIN: N/A
Carrier: ATT
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Dougsg38p View Post
I don't see where your StringToDate is ever called, or where the value is ever displayed.
how would i call it, or display it?
sorry im new to java.

thanx for reply
Offline  
Old 02-17-2010, 11:53 AM   #4 (permalink)
New Member
 
Join Date: Feb 2010
Model: 7600
PIN: N/A
Carrier: ATT
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok to call the StringToDate function above im doing this

Code:
	public ClockScreen()
	{
		Date d = new Date();
		LabelField t = new LabelField("Current Time is",
			LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
		setTitle(t);
		ClockScreen f = new ClockScreen();
		d.getTime();
		f.StringToDate(d.toString());		
		
	}

im getting stack overflow error.
how do i display and position the result?

I think my problem above is that i am making a new clock screen?

Last edited by j0k3r9162 : 02-17-2010 at 12:00 PM.
Offline  
Old 02-17-2010, 02:30 PM   #5 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

I think you need to start with the sample programs that are shipped with the JDE, and purchase a good Java book while you are at it.

You cannot instantiate a class from within the constructor of that class. This will result in a stack fault (as you have already seen).

There are three "Blackberry" development books in print, you should invest in one of them.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.