java - Adding time and date to google calendar via intent -



java - Adding time and date to google calendar via intent -

i trying add together event google calendar using object have stored on database. date stored on database stored in format of date , time stored string.

currently working bar time portion of event. date beingness passed correctly time defaulting 0:00. how create time passed properly?

@override public void onclick(view arg0) { if(arg0.getid() == r.id.btnaddtocal) { long starttime = 0, endtime=0; string startdate = blankevent.eventdate; seek { date date = new simpledateformat("yyyy-mm-dd").parse(startdate); starttime=date.gettime(); } catch(exception e){ } calendar cal = calendar.getinstance(); intent calintent = new intent(intent.action_edit); calintent.settype("vnd.android.cursor.item/event"); calintent.putextra("eventlocation", blankevent.eventlocation); calintent.putextra("title", blankevent.eventname); calintent.putextra("description", blankevent.eventdetails); calintent.putextra("begintime",starttime); calintent.putextra("dtstart", blankevent.eventtime); startactivity(calintent); return; }

i have attached screenshot of actual problem area. date right time incorrect.

solved code

@override public void onclick(view arg0) { // todo auto-generated method stub log.e("cal","sel2"); if(arg0.getid() == r.id.btnaddtocal) { string startdate = blankevent.eventdate; string starthour = blankevent.eventtime; date fulldate = null; seek { fulldate = new simpledateformat("yyyy-mm-dd-hh:mm").parse(startdate+"-"+starthour); } grab (parseexception e) { e.printstacktrace(); } calendar cal = calendar.getinstance(); intent calintent = new intent(intent.action_edit); calintent.settype("vnd.android.cursor.item/event"); calintent.putextra("eventlocation", blankevent.eventlocation); calintent.putextra("title", blankevent.eventname); calintent.putextra("description", blankevent.eventdetails); calintent.putextra("begintime", fulldate.gettime()); calintent.putextra("endtime",fulldate.gettime()+60*60*1000); startactivity(calintent); return; }

your starttime needs miliseconds. dont intent fields names.

since parse dd--mm--yyyy time still left @ 00:00 , , default duration of event 1 hour. have set time of date object (starttime) , phone call starttime.getmillis();

string startdate = blankevent.eventdate; string starthour = blankevent.eventtime; date date = new simpledateformat("yyyy-mm-dd-hh:mm").parse(startdate+"-"+starthour);

also, here clean illustration www.developer.com lauren darcey & shane conder

intent calintent = new intent(intent.action_insert); calintent.setdata(events.content_uri); calintent.putextra(events.title, "google io afterparty"); calintent.putextra(events.event_location, "the w hotel bar on 3rd street"); calintent.putextra(events.description, "hang out after google io drink , geeky conversation."); calendar starttime = calendar.getinstance(); starttime.set(2012, 5, 29, 18, 0); calendar endtime = calendar.getinstance(); endtime.set(2012, 5, 29, 22, 30); calintent.putextra(calendarcontract.extra_event_begin_time, starttime.gettimeinmillis()); calintent.putextra(calendarcontract.extra_event_end_time, endtime.gettimeinmillis()); startactivity(calintent);

java android date time calendar

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -