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
Developer
Posts: 1,006
Registered: ‎05-22-2009
My Device: Not Specified

Doubts in DateField

Hi i am developing my custom component,so in that i need to place the datefield in center of form,

 

with buttons surrounding that component.So

 

1)I want to set the dateField component to center.I tried with using following code

 SimpleDateFormat SDF = new SimpleDateFormat("dd/MM/yyyy");
        df=new DateField("",0 , SDF,DateField.FIELD_HCENTER|DateField.DATE);
        this.add(df);

 

 

I cannot get it in center.How to get it in the center.

 

2)This datefield shows the present date,so if i want the DateField to show the given date,how to do it in datefield.

 

 

 

Regards

Rakesh Shankar.P

Developer
Posts: 467
Registered: ‎07-16-2009
My Device: Z10 LE
My Carrier: Vodafone NL

Re: Doubts in DateField

Hi, 

 

I'm not sure about the first question - all looks fine.

For the second one please use DateField.setDate().

 

Thanks,

Eugen

Developer
Posts: 1,006
Registered: ‎05-22-2009
My Device: Not Specified

Re: Doubts in DateField

When i use DateField.setDate() it asks for date object.Any ideas on how to create it(Date Object this is from J2ME right)?

any sample codes will be helpful.

 

Regarding the first qn,we have change(override)to width of the component,using Prefferred width method,and i added in HorizontalFieldManager,i am getting it partially ,and working on it

 

 

 

Regards

 

Rakesh Shankar.P

Developer
Posts: 16,999
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Doubts in DateField

Date date = new Date();

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 467
Registered: ‎07-16-2009
My Device: Z10 LE
My Carrier: Vodafone NL

Re: Doubts in DateField

[ Edited ]

Date date = new Date(System.currentTimeMillis()) //long variable any time that you need

Developer
Posts: 1,006
Registered: ‎05-22-2009
My Device: Not Specified

Re: Doubts in DateField

[ Edited ]

Hello guys,if i want to set the date as 30/6/2009.How to set the date in milliseconds.I cant get it

 

Developer
Posts: 16,999
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Doubts in DateField

create a calendar object, set the day/month/year value, call getTime on it

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 1,006
Registered: ‎05-22-2009
My Device: Not Specified

Re: Doubts in DateField

I am presently using DateField component,i want to set any date,similarly i have to get the next day and previous days date,when i press next and previous button

 

i want to set the particular date in DateField

 

for that i  require date object ,and for setting the date object  ,we need calendar and i want to know how to set the date in calendar

 

 

i tried with creating a object and then i dont know ,how to do it

 

Calendar cal=Calendar.getInstance();

 

how to set the date,month and yr value

 

 

Developer
Posts: 16,999
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Doubts in DateField

how about reading the API?

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter