java - Android set date and time is not displaying in log cat -


my code

used fetching date , time in android-java

try {             simpledateformat sdf = new simpledateformat(                     "yyyy-mm-dd", locale.us);             string currentdateandtime = sdf.format(new date());             final file path = new file(environment.getexternalstoragedirectory(), "smok_komunal");             if (!path.exists()) {                 path.mkdir();             }             log.e("path ", path.getabsolutepath()+ " , "+currentdateandtime );              runtime.getruntime().exec("logcat  -f " + path + file.separator + "dbo_logcat_" + currentdateandtime + ".txt");         } catch (ioexception e) {             e.printstacktrace();         } 

while logging value .it doesn't display date , time... can me?

 try {                 simpledateformat sdf = new simpledateformat(                         "yyyy-mm-dd", locale.us);                 string currentdateandtime = sdf.format(new date());                 final file path = new file(environment.getexternalstoragedirectory(), "smok_komunal");                 if (!path.exists()) {                     path.mkdir();                 }                 log.e("path ",""+path.getabsolutepath());                 log.e("currentdateandtime",""+currentdateandtime );                  runtime.getruntime().exec("logcat  -f " + path + file.separator + "dbo_logcat_" + currentdateandtime + ".txt");             } catch (ioexception e) {                 e.printstacktrace();             } 

android :to date , time

public string timezone          =   timezone.getdefault().getid(); 

if using pure android can follow above timezone

if using java can follow below code print date , time http://beginnersbook.com/2013/05/current-date-time-in-java/ refer this

if using android oncreate

use code.. got output

public void oncreate(bundle savedinstancestate) {  super.oncreate(savedinstancestate);  //setcontentview(r.layout.main);   calendar c = calendar.getinstance();  system.out.println("current time => "+c.gettime());   simpledateformat df = new simpledateformat("yyyy-mm-dd hh:mm:ss");  string formatteddate = df.format(c.gettime());  // formatteddate have current date/time  toast.maketext(this, formatteddate, toast.length_short).show();    // display formatteddate value in textview  textview txtview = new textview(this);  txtview.settext("current date , time : "+formatteddate);  txtview.setgravity(gravity.center);  txtview.settextsize(20);  setcontentview(txtview);  } 

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -