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
Regular Contributor
Posts: 52
Registered: ‎02-26-2013
My Device: Curve 9650,Bold 9900
My Carrier: Airtel
Accepted Solution

Convert Date to Milliseconds

DateTimePicker datePicker2 = DateTimePicker.createInstance();
               datePicker2.doModal();
                Calendar cal = datePicker2.getDateTime();
          Date date = cal.getTime();
          TimeZone _timeZone = TimeZone.getDefault();

          int month = cal.get(Calendar.MONTH);
          int year = cal.get(Calendar.YEAR);
          int date =cal.get(Calendar.DATE);
          int day = cal.get(Calendar.DAY_OF_WEEK);
          int hour = cal.get(Calendar.HOUR);
          int min = cal.get(Calendar.MINUTE);
          int sec = cal.get(Calendar.SECOND);
          
          int miliS33 = cal.get(Calendar.MILLISECOND);

 

I get all fields of selected date using datetimepicker but i just want to convert this date in to milliseconds ,How could i do this..i have already used

long gmtOffset = _timeZone.getOffset(1, year, month, date,day,miliS); but this does not work for me .

plz Give suggestion with some code...!

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Convert Date to Milliseconds

<calendar>.getTime().getTime()?

Regular Contributor
Posts: 52
Registered: ‎02-26-2013
My Device: Curve 9650,Bold 9900
My Carrier: Airtel

Re: Convert Date to Milliseconds

Thanks peter_strange it works for me...!