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.

inside custom component

Java Development

Reply
Contributor
Posts: 49
Registered: ‎05-02-2012
My Device: Bold 9790
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

Developer
Posts: 139
Registered: ‎02-23-2012
My Device: Blackberry bold
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
Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Date Field with the day of the week?

Contributor
Posts: 49
Registered: ‎05-02-2012
My Device: Bold 9790
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);

 

Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

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.

 

Highlighted
Contributor
Posts: 49
Registered: ‎05-02-2012
My Device: Bold 9790
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.