Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Contributor
beenjaminnn
Posts: 42
Registered: ‎05-02-2012
My Carrier: Wind Mobile

Date Field with the day of the week?

Hi,

 

I'd like to create a date field with the day of the week. Currently I can make one with the day of month, month and year but I'd like to have one with the day of the week, day of month, month and year.

Right now I have:

DateField dateField = new DateField("Go to:",System.currentTimeMillis(), DateField.DATE);

 Can I adapt this to include the day of week too?

 

Ben

Please use plain text.
Developer
MohammedAziz
Posts: 139
Registered: ‎02-23-2012
My Carrier: Vodafone India

Re: Date Field with the day of the week?

You can use Calender class to obtain what you require

http://www.blackberry.com/developers/docs/4.5.0api/java/util/Calendar.html

Thank you
warm regards
Mohammed Aziz
Please use plain text.
Developer
maadani
Posts: 729
Registered: ‎05-04-2011

Re: Date Field with the day of the week?

Please use plain text.
Contributor
beenjaminnn
Posts: 42
Registered: ‎05-02-2012
My Carrier: Wind Mobile

Re: Date Field with the day of the week?

So something like this?

DateField dateField = new DateField("Go to:",System.currentTimeMillis(), DateField.DATE);
dateField.setFormat(DateFormat.DATE_LONG);

 

Please use plain text.
Developer
maadani
Posts: 729
Registered: ‎05-04-2011

Re: Date Field with the day of the week?

Actually, more like:

dateField.setFormat(DateFormat.getInstance(DateFormat.DATE_LONG));

 

Another option, which I prefer, is:

dateField.setFormat(new SimpleDateFormat("your Date Format Pattern Here"));

 

The simpleDateFormat class lets you define your own preferred date pattern:

http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/i18n/SimpleDateFormat.html

 

E.

 

Please use plain text.
Contributor
beenjaminnn
Posts: 42
Registered: ‎05-02-2012
My Carrier: Wind Mobile

Re: Date Field with the day of the week?

Thank you,

 

But tha still doesn't seem to be working. I'm using Eclipse and it gives me the error

"Syntax error on token "setFormat", Identifier expected after this token"

I used dateField.setFormat(DateFormat.getInstance(DateFormat.DATE_LONG));

It seems to be a problem with setFormat, not anything else.

Please use plain text.