Return formatted time

Im trying to get the time a button is pressed and display it on the

                       statuschange.setText("To Movies");
                       Time now = new Time();
                       timeofchange.setText("" + now);

Open in new window

and it returns 20120401T232303GMT(0,91,0,0,1333322583)

Im trying to get the time formatted  YYYYMMDDTHHMMSS format  ... is
this the best way to do this ?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I think SImpleDateFormat will work with Androiud as elsewhere in java

I think somethidk like that should work:

SimpleDateFormat sdf = new SimpleDateFormat(" "yyyyMMddHHmmssSSSZ":

java.util.Date dd = new java.util.Date();

This is the test:
SimpleDateFormat sdf0401 = new SimpleDateFormat("yyyyMMddHHmmss");

java.util.Date dd0401 = new java.util.Date();


Open in new window



Open in new window

Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

If you want to have "T" in between, then you probably want to do it this way:

SimpleDateFormat sdf0401 = new SimpleDateFormat("yyyyMMdd");

        SimpleDateFormat sdf0402 = new SimpleDateFormat("HHmmss");

java.util.Date dd0401 = new java.util.Date();

        System.out.println(sdf0401.format(dd0401) +"T"+sdf0402.format(dd0401));

Open in new window


Open in new window

dolamitejenkinsAuthor Commented:
its keeps crashing android

04-02 04:04:48.368: E/AndroidRuntime(306):       at$

04-02 04:04:48.368: E/AndroidRuntime(306):       at

I cant really see the error because eclipse is tough to debug in /
I tried using SimpleDateFormat and java.util.Date
in the HelloAndroid project and it worked fine in the emulator

package com.exmple.helloandroid;

import java.text.SimpleDateFormat;

import android.os.Bundle;
import android.text.Layout;
import android.widget.TableLayout;
import android.widget.TextView;

public class HelloAndroidActivity extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {

        TextView tv = new TextView(this);
     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
     java.util.Date dd = new java.util.Date();
        tv.setText("Hello, absolutely new Android,  " + sdf.format(dd));

       // setContentView(R.layout.main);

Open in new window

androis with time

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dolamitejenkinsAuthor Commented:
Thank you that worked ....
dolamitejenkinsAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.