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: 415
Registered: ‎07-28-2010
My Device: 8000
My Carrier: hi

how i get current date and time in YYYY-MM-DD formate

hello friends,

                  i want to check current date and time in the formate YYYY-MM-DD formate any one help me frnds..

thanks and regards,

      Ajay Patil.

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

Re: how i get current date and time in YYYY-MM-DD formate

http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/i18n/DateFormat.html
or
http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/i18n/SimpleDateFormat.html
----------------------------------------------------------
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: 415
Registered: ‎07-28-2010
My Device: 8000
My Carrier: hi

Re: how i get current date and time in YYYY-MM-DD formate

any one give me example? can you send me small example....

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

Re: how i get current date and time in YYYY-MM-DD formate

the API contains examples.
----------------------------------------------------------
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: 243
Registered: ‎07-22-2011
My Device: BlackBerry Z10
My Carrier: AirTel

Re: how i get current date and time in YYYY-MM-DD formate

Hi,

 

        Date today = new Date(System.currentTimeMillis());
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String curDate = format.format(today);

Regards,

Lakshman

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

Developer
Posts: 285
Registered: ‎08-26-2011
My Device: 9900
My Carrier: Not Specified

Re: how i get current date and time in YYYY-MM-DD formate

[ Edited ]

Try this one: 

 

SimpleDateFormat formate = new SimpleDateFormat("yyyy-MM-dd HH:mm:sss");
 String newTime = formate.formatLocal(System.currentTimeMillis());
System.out.println("======================Date: "+newTime);

I got this output:

 

======================Date: 2012-01-31 14:45:55

 

 =================================================================

Feel free to click LIKE button if the solution is corret;

=================================================================================
Feel free to click LIKE button if the solution helps you;
--
Regards,

ALI SHAIK.
Developer
Posts: 139
Registered: ‎10-24-2010
My Device: BlackBerry 10 Dev Alpha
My Carrier: du

Re: how i get current date and time in YYYY-MM-DD formate

SimpleDateFormat sdf = new SimpleDateFormat("EEE@HH:mm");

or

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

 

or any format which you want you can give inside of  SampleDateFormat constructor

 


String changedate = sdf.format(new Date(System.currentTimeMillis()));

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