BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 05-06-2008, 11:00 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2007
Location: Cincinnati, OH
Model: 8700c
PIN: N/A
Carrier: Cingular
Posts: 87
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default DateField - left align text - how to?

Please Login to Remove!

net.rim.device.api.ui.component.DateField

Hi Folks,

I'm trying to left align the text in a DateField. Thought it would be something simple like:

Code:
DateField df = new DateField( "", System.currentTimeMillis(), DateField.FIELD_LEFT);
or

Code:
DateField df = new DateField( "", System.currentTimeMillis(), net.rim.device.api.ui.DrawStyle.LEFT);
Either way compiles, but either way gives me an exception:

java.lang.IllegalArgumentException



Any ideas?

Thanks in advance
Offline  
Old 05-07-2008, 02:20 AM   #2 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

The same procedure as every year. Extend Field and implement your own draw-method.
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 05-07-2008, 10:37 AM   #3 (permalink)
Talking BlackBerry Encyclopedia
 
richard.puckett's Avatar
 
Join Date: Oct 2007
Location: Seattle, WA
Model: 9020
PIN: N/A
Carrier: T-Mobile
Posts: 212
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

From the api docs:

Quote:
This builds a date field, inferring the required date format for this field from the style parameter you provide. Thus, at the very least, style must include one of DATE, TIME, or DATE_TIME.
Try adding (bitwise) one of the DateTime styles to your draw style. The following works for me.

Code:
DateField df = new DateField("", System.currentTimeMillis(), DateField.DATE_TIME | DrawStyle.LEFT);
__________________
Do your homework and know how to ask a good question.
Offline  
Old 05-12-2008, 11:09 AM   #4 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2007
Location: Cincinnati, OH
Model: 8700c
PIN: N/A
Carrier: Cingular
Posts: 87
Post Thanks: 0
Thanked 0 Times in 0 Posts
Smile Thanks!

Thanks guys.

Richard, your suggestion works perfectly!

Here is an interesting side note: I'm using the 4.1 API documentation (since I'm using the 4.1 JDE), which does not mention the required use of DATE, TIME, or DATE_TIME style bits (though it makes perfect sense after you pointed it out). I found this rather strange so I "google searched" part of the phrase and found that the 4.2 API documentation DOES indeed read just like you quoted. Looks like they've updated their documentation since 4.1

4.1 documentation:
RIM Device Java Library: Class DateField)

4.2 documentation:
RIM Device Java Library: Class DateField)

Anyway, thanks again for your help!
Offline  
Old 05-12-2008, 04:44 PM   #5 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by bbCincinnati View Post
I found this rather strange
The fun fun world of blackberry development!
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 05-13-2008, 07:33 AM   #6 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2007
Location: Cincinnati, OH
Model: 8700c
PIN: N/A
Carrier: Cingular
Posts: 87
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

he he he
Offline  
Old 05-19-2008, 08:28 AM   #7 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2008
Model: 8100
PIN: N/A
Carrier: Airtel
Posts: 19
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by bbCincinnati View Post
he he he
dateField = new DateField("",System.currentTimeMillis(),DateField. TIME|DrawStyle.LEFT);
Offline  
Old 05-19-2008, 09:29 AM   #8 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2007
Location: Cincinnati, OH
Model: 8700c
PIN: N/A
Carrier: Cingular
Posts: 87
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks navneet
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.