how to set current date in application in android without datepicker.please tell me how to write code -
how to set current date in application in android without datepicker.please tell me how to write code -
package com.example.productstock; import java.text.dateformat; import java.text.simpledateformat; import java.util.calendar; import java.util.date; import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.view; import android.widget.button; import android.widget.textview; public class categoriesactivity extends activity { textview t1; button b1; textview date; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.categories); t1=(textview) findviewbyid(r.id.textview1); b1=(button) findviewbyid(r.id.button1); calendar cal = calendar.getinstance(); calendar dt = calendar.getinstance(); dt.clear(); dt.set(cal.get(calendar.year), cal.get(calendar.month),cal.get(calendar.date)); return; b1.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { intent i1=new intent(categoriesactivity.this,boxesactivity.class); startactivity(i1); } });
do
calendar cal = calendar.getinstance(); int year = cal.get(calendar.year); int month = cal.get(calendar.month); int day = cal.get(calendar.day_of_month); //get string values e.g string yearstr = integer.tostring(year); //finally, concatinate string monthstr+" "daystr+", "yearstr
android
Comments
Post a Comment