Example usage for java.text DateFormat getDateTimeInstance

List of usage examples for java.text DateFormat getDateTimeInstance

Introduction

In this page you can find the example usage for java.text DateFormat getDateTimeInstance.

Prototype

public static final DateFormat getDateTimeInstance() 

Source Link

Document

Gets the date/time formatter with the default formatting style for the default java.util.Locale.Category#FORMAT FORMAT locale.

Usage

From source file:com.messagesight.mqtthelper.MqttHandler.java

public void messageArrived(String topic, MqttMessage message) {

    //send notification
    int duration = Toast.LENGTH_SHORT;
    String text = "message Received:" + topic;
    Toast toast = Toast.makeText(ctx, text, duration);
    // toast.show();

    //save payload in an arrayList
    List messageRecvd = new ArrayList<String>();
    messageRecvd.add(message.toString());

    String uniqueTopic = topic + ":" + UUID.randomUUID().toString();

    payload.put(uniqueTopic, messageRecvd);
    topicsReceived.add(uniqueTopic);/*  w  ww .j a  va 2 s.c  o m*/

    //broadcast message received to payload class
    Intent intent = new Intent("payload");
    intent.putExtra("topic", topic.toString());
    intent.putExtra("message", message.toString());
    LocalBroadcastManager.getInstance(ctx).sendBroadcast(intent);

    //print to the log screen
    String time = "<" + DateFormat.getDateTimeInstance().format(new Date()) + ">";
    String messageRecv = time + ":" + topic + "<S>: " + message + "\n";
    MyActivity.logScreen.append(messageRecv);
}

From source file:com.cosmicsubspace.nerdyaudio.ui.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    final Thread.UncaughtExceptionHandler orig = Thread.getDefaultUncaughtExceptionHandler();
    final Context c = getApplicationContext();
    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        @Override/*from w  ww  .j av  a  2s.  com*/
        public void uncaughtException(Thread thread, Throwable e) {
            Log2.log(0, this, "UncaughtException logged:", Log2.logToString(e));
            //Toast.makeText(c, ErrorLogger.logToString(e), Toast.LENGTH_SHORT).show();
            FileWriter f;
            try {
                f = new FileWriter(new File(Environment.getExternalStorageDirectory() + "/AFN_exceptions.txt"),
                        true);
                f.write("\n\n\n" + DateFormat.getDateTimeInstance().format(new Date()) + "\n");
                f.write(Log2.logToString(e));
                f.flush();
                f.close();
            } catch (IOException e1) {
                Log2.log(e1);
            } //Double exception?

            Log2.dumpLogsAsync();

            orig.uncaughtException(thread, e);
        }
    });

    requestPermission();

    Log2.log(1, this, "MainActivity Created!");

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    sf = getPreferences(Context.MODE_PRIVATE);

    String[] files = fileList();
    for (String i : files) {
        Log2.log(1, this, "File: " + i);
    }

    qm = QueueManager.getInstance();
    ap = AudioPlayer.getInstance();
    vb = VisualizationBuffer.getInstance();
    fm = FileManager.getInstance();
    wf = Waveform.getInstance();
    sbs = SidebarSettings.instantiate(getApplicationContext());
    vm = VisualizationManager.getInstance();

    volCtrl = new VolumeControls(getApplicationContext(), qm);

    //ap.setBufferFeedListener(vb);

    qm.passContext(getApplicationContext());
    fm.loadFromFile(this);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    tabLayout.addTab(tabLayout.newTab().setText("Library"));
    tabLayout.addTab(tabLayout.newTab().setText("Queue"));
    tabLayout.addTab(tabLayout.newTab().setText("Filters"));
    tabLayout.addTab(tabLayout.newTab().setText("Now Playing"));
    tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);

    tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            int pos = tab.getPosition();
            if (pos == 0)
                ft.replace(R.id.tab_area, new LibraryFragment());
            else if (pos == 1)
                ft.replace(R.id.tab_area, new QueueFragment());
            else if (pos == 2)
                ft.replace(R.id.tab_area, new FiltersFragment());
            else if (pos == 3)
                ft.replace(R.id.tab_area, new NowPlayingFragment());

            ft.commit();
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {

        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {

        }
    });
    getSupportFragmentManager().beginTransaction().replace(R.id.tab_area, new LibraryFragment()).commit();

    wfv = (PlayControlsView) findViewById(R.id.waveform);
    wfv.setSpacing(0);
    wfv.setTimestampVisibility(true);
    wfv.setTimestampSize(16);
    wfv.setTimestampColor(Color.WHITE);

    wfv.setTimestampOffset(30, 10);
    wfv.setTimestampBackgroundColor(Color.argb(128, 0, 0, 0));

    wfv.setWaveform(wf);
    qm.addQueueListener(wfv);
    qm.addProgressStringListener(wfv);

    vv = (VisualizationView) findViewById(R.id.visualization);

    dl = (DrawerLayout) findViewById(R.id.drawer_layout);

    dl.setDrawerListener(this);

    settingBtn = (RelativeLayout) findViewById(R.id.settings_btn);
    settingBtn.setOnClickListener(this);

    //statusText=(TextView)findViewById(R.id.status);

    sideContainer = (ScrollView) findViewById(R.id.drawer_scroll);
    sideContainer.addView(sbs.getView(getLayoutInflater(), sideContainer, null));

}

From source file:com.nextgis.maplibui.formcontrol.DateTime.java

@Override
public void init(JSONObject element, List<Field> fields, Bundle savedState, Cursor featureCursor,
        SharedPreferences preferences) throws JSONException {
    JSONObject attributes = element.getJSONObject(JSON_ATTRIBUTES_KEY);
    mFieldName = attributes.getString(JSON_FIELD_NAME_KEY);
    mIsShowLast = ControlHelper.isSaveLastValue(attributes);

    if (!ControlHelper.isEnabled(fields, mFieldName)) {
        setEnabled(false);/* www . j a va2s. c o m*/
        getBackground().setColorFilter(Color.GRAY, PorterDuff.Mode.SRC_ATOP);
    }

    if (attributes.has(JSON_DATE_TYPE_KEY)) {
        mPickerType = attributes.getInt(JSON_DATE_TYPE_KEY);
    }

    switch (mPickerType) {

    case 0:
        mDateFormat = (SimpleDateFormat) DateFormat.getDateInstance();
        mPickerType = GeoConstants.FTDate;
        break;

    case 1:
        mDateFormat = (SimpleDateFormat) DateFormat.getTimeInstance();
        mPickerType = GeoConstants.FTTime;
        break;

    default:
        mPickerType = FTDateTime;
    case 2:
        mDateFormat = (SimpleDateFormat) DateFormat.getDateTimeInstance();
        mPickerType = GeoConstants.FTDateTime;
        break;
    }

    long timestamp = System.currentTimeMillis();
    if (ControlHelper.hasKey(savedState, mFieldName)) {
        timestamp = savedState.getLong(ControlHelper.getSavedStateKey(mFieldName));
    } else if (null != featureCursor) { // feature exists
        int column = featureCursor.getColumnIndex(mFieldName);
        if (column >= 0) {
            timestamp = featureCursor.getLong(column);
        }
    } else { // new feature
        if (attributes.has(JSON_TEXT_KEY) && !TextUtils.isEmpty(attributes.getString(JSON_TEXT_KEY).trim())) {
            String defaultValue = attributes.getString(JSON_TEXT_KEY);
            timestamp = parseDateTime(defaultValue, mPickerType);
        }

        if (mIsShowLast) {
            timestamp = preferences.getLong(mFieldName, timestamp);
        }
    }

    mCalendar.setTimeInMillis(timestamp);
    setText(mDateFormat.format(mCalendar.getTime()));
    setSingleLine(true);
    setFocusable(false);
    setOnClickListener(getDateUpdateWatcher(mPickerType));

    String pattern = mDateFormat.toLocalizedPattern();
    setHint(pattern);
}

From source file:com.QuarkLabs.BTCeClientJavaFX.PublicTradesController.java

@FXML
void initialize() {
    assert publicTradesTable != null : "fx:id=\"publicTradesTable\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTableAmountColumn != null : "fx:id=\"publicTradesTableAmountColumn\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTableDateColumn != null : "fx:id=\"publicTradesTableDateColumn\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTableItemColumn != null : "fx:id=\"publicTradesTableItemColumn\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTablePriceColumn != null : "fx:id=\"publicTradesTablePriceColumn\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTablePriceCurrencyColumn != null : "fx:id=\"publicTradesTablePriceCurrencyColumn\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTableTIDColumn != null : "fx:id=\"publicTradesTableTIDColumn\" was not injected: check your FXML file 'markettrades.fxml'.";
    assert publicTradesTableTradeTypeColumn != null : "fx:id=\"publicTradesTableTradeTypeColumn\" was not injected: check your FXML file 'markettrades.fxml'.";

    publicTradesTable.setItems(publicTrades);
    publicTradesTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    publicTradesTableAmountColumn.setCellValueFactory(new PropertyValueFactory<PublicTrade, Double>("amount"));
    publicTradesTableDateColumn.setCellValueFactory(
            new Callback<TableColumn.CellDataFeatures<PublicTrade, String>, ObservableValue<String>>() {
                @Override/*  w w w .j ava2  s .c  o m*/
                public ObservableValue<String> call(
                        TableColumn.CellDataFeatures<PublicTrade, String> publicTradeStringCellDataFeatures) {
                    PublicTrade publicTrade = publicTradeStringCellDataFeatures.getValue();
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTimeInMillis(publicTrade.getDate() * 1000);
                    DateFormat dateFormat = DateFormat.getDateTimeInstance();
                    return new SimpleStringProperty(dateFormat.format(calendar.getTime()));
                }
            });
    publicTradesTableItemColumn.setCellValueFactory(new PropertyValueFactory<PublicTrade, String>("item"));
    publicTradesTablePriceColumn.setCellValueFactory(new PropertyValueFactory<PublicTrade, Double>("price"));
    publicTradesTablePriceCurrencyColumn
            .setCellValueFactory(new PropertyValueFactory<PublicTrade, String>("priceCurrency"));
    publicTradesTableTIDColumn.setCellValueFactory(new PropertyValueFactory<PublicTrade, Long>("tid"));
    publicTradesTableTradeTypeColumn
            .setCellValueFactory(new PropertyValueFactory<PublicTrade, String>("tradeType"));

    Task<JSONArray> loadPublicTrades = new Task<JSONArray>() {
        @Override
        protected JSONArray call() throws Exception {
            return App.getPublicTrades(pair);
        }
    };
    loadPublicTrades.setOnSucceeded(new EventHandler<WorkerStateEvent>() {
        @Override
        public void handle(WorkerStateEvent workerStateEvent) {
            JSONArray jsonArray = (JSONArray) workerStateEvent.getSource().getValue();
            publicTrades.clear();
            for (int i = 0; i < jsonArray.length(); i++) {
                JSONObject item = jsonArray.getJSONObject(i);
                PublicTrade publicTrade = new PublicTrade();
                publicTrade.setDate(item.getLong("date"));
                publicTrade.setAmount(item.getDouble("amount"));
                publicTrade.setItem(item.getString("item"));
                publicTrade.setPrice(item.getDouble("price"));
                publicTrade.setPriceCurrency(item.getString("price_currency"));
                publicTrade.setTid(item.getLong("tid"));
                publicTrade.setTradeType(item.getString("trade_type"));
                publicTrades.add(publicTrade);
            }
        }
    });
    Thread thread = new Thread(loadPublicTrades);
    thread.start();
}

From source file:loaders.SmapTaskLoader.java

private void getTasks(ArrayList<TaskEntry> entries) {
    // Get cursor
    if (mTaskListCursor == null || mTaskListCursor.isClosed()) {
        FileDbAdapter fda = new FileDbAdapter();
        fda.open();/*from  w  ww .  j  a v  a  2 s.  c om*/
        try {
            mTaskListCursor = fda.fetchTasksForSource(Utilities.getSource(), true);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            fda.close();
        }
    }

    if (mTaskListCursor != null && !mTaskListCursor.isClosed()) {
        mTaskListCursor.moveToFirst();
        DateFormat dFormat = DateFormat.getDateTimeInstance();
        while (!mTaskListCursor.isAfterLast()) {

            TaskEntry entry = new TaskEntry(this);
            entry.type = "task";
            entry.name = mTaskListCursor.getString(mTaskListCursor.getColumnIndex(FileDbAdapter.KEY_T_TITLE));
            entry.status = mTaskListCursor
                    .getString(mTaskListCursor.getColumnIndex(FileDbAdapter.KEY_T_STATUS));
            entry.taskStart = dFormat.format(mTaskListCursor
                    .getLong(mTaskListCursor.getColumnIndex(FileDbAdapter.KEY_T_SCHEDULED_START)));
            entry.taskAddress = mTaskListCursor
                    .getString(mTaskListCursor.getColumnIndex(FileDbAdapter.KEY_T_ADDRESS));
            entry.taskForm = mTaskListCursor
                    .getString(mTaskListCursor.getColumnIndex(FileDbAdapter.KEY_T_TASKFORM));
            entry.instancePath = mTaskListCursor
                    .getString(mTaskListCursor.getColumnIndex(FileDbAdapter.KEY_T_INSTANCE));
            entry.id = mTaskListCursor.getLong(mTaskListCursor.getColumnIndex(FileDbAdapter.KEY_T_ID));

            entries.add(entry);
            mTaskListCursor.moveToNext();
        }
    }
}

From source file:com.google.android.gcm.demo.ui.InstanceIdFragment.java

@Override
public void refresh() {
    new AsyncTask<Void, Void, Void>() {
        @Override//from   ww  w .  java  2s  .  co  m
        protected Void doInBackground(Void... params) {
            final String instanceId = mInstanceIdHelper.getInstanceId();
            final String creationTime = DateFormat.getDateTimeInstance()
                    .format(new Date(mInstanceIdHelper.getCreationTime()));
            final Activity activity = getActivity();
            if (activity != null) {
                Handler handler = new Handler(activity.getMainLooper());
                handler.post(new Runnable() {
                    public void run() {
                        setValue(activity.findViewById(R.id.iid_instance_id), instanceId);
                        setValue(activity.findViewById(R.id.iid_creation_time), creationTime);
                    }
                });
            }
            return null;
        }
    }.execute();
    float density = getActivity().getResources().getDisplayMetrics().density;
    SimpleArrayMap<String, Sender> addressBook = mSenders.getSenders();
    LinearLayout sendersList = new LinearLayout(getActivity());
    sendersList.setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < addressBook.size(); i++) {
        Sender sender = addressBook.valueAt(i);
        if (sender.appTokens.size() > 0) {
            LinearLayout senderRow = (LinearLayout) getActivity().getLayoutInflater()
                    .inflate(R.layout.widget_icon_text_button_row, sendersList, false);
            ImageView senderIcon = (ImageView) senderRow.findViewById(R.id.widget_itbr_icon);
            TextView senderLabel = (TextView) senderRow.findViewById(R.id.widget_itbr_text);
            senderRow.findViewById(R.id.widget_itbr_button).setVisibility(View.GONE);
            senderIcon.setImageResource(R.drawable.cloud_googblue);
            senderIcon.setPadding(0, 0, (int) (8 * density), 0);
            senderLabel.setText(getString(R.string.topics_sender_id, sender.senderId));
            sendersList.addView(senderRow);
            for (Token token : sender.appTokens.values()) {
                LinearLayout row = (LinearLayout) getActivity().getLayoutInflater()
                        .inflate(R.layout.widget_icon_text_button_row, sendersList, false);
                ImageView icon = (ImageView) row.findViewById(R.id.widget_itbr_icon);
                TextView label = (TextView) row.findViewById(R.id.widget_itbr_text);
                Button button = (Button) row.findViewById(R.id.widget_itbr_button);
                icon.setImageResource(R.drawable.smartphone_grey600);
                label.setText(token.scope + " - " + AbstractFragment.truncateToMediumString(token.token));
                button.setText(R.string.iid_delete_token);
                button.setTag(R.id.tag_senderid, sender.senderId);
                button.setTag(R.id.tag_scope, token.scope);
                button.setOnClickListener(this);
                row.setPadding((int) (16 * density), 0, 0, 0);
                sendersList.addView(row);
            }
        }
    }
    if (sendersList.getChildCount() == 0) {
        TextView noTokens = new TextView(getActivity());
        noTokens.setText(getString(R.string.iid_no_tokens));
        noTokens.setTypeface(null, Typeface.ITALIC);
        sendersList.addView(noTokens);
    }
    FrameLayout tokensView = (FrameLayout) getActivity().findViewById(R.id.iid_tokens_wrapper);
    tokensView.removeAllViews();
    tokensView.addView(sendersList);
}

From source file:com.measurence.sdk.android.demo.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo);
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction().add(R.id.container, new NotificationsFragment())
                .commit();/*from ww w.j  ava2  s .c om*/
    }
    checkRegistration();
    subscriptionResultBroadcastReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            String subscriptionResultMessage = intent
                    .getStringExtra(MeasurenceApiSubscriptionService.SUBSCRIPTION_RESULT_INTENT_MESSAGE);
            displaySubscriptionResultMessage(subscriptionResultMessage);
        }
    };

    if (presenceNotificationsListAdapter == null) {
        presenceNotificationsListAdapter = new ArrayAdapter<PresenceNotification>(this,
                R.layout.list_item_notification, R.id.list_item_notification_view,
                new ArrayList<PresenceNotification>()) {

            DateFormat dateFormat = DateFormat.getDateTimeInstance();

            private void setText(View root, int id, String text) {
                TextView textView = (TextView) root.findViewById(id);
                textView.setText(text);
            }

            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                LayoutInflater inflater = (LayoutInflater) getContext()
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                View itemView = inflater.inflate(R.layout.list_item_notification, null);
                PresenceNotification notification = getItem(position);
                PresenceSessionUpdate item = notification.presenceSessionUpdate;
                String now = dateFormat.format(notification.received);
                setText(itemView, R.id.list_item_notification_date, now);
                StringBuilder sb = new StringBuilder();
                for (UserIdentity userid : item.getUserIdentities()) {
                    sb.append(userid.getId()).append(" ");
                }
                setText(itemView, R.id.list_item_notification_userid, sb.toString());
                setText(itemView, R.id.list_item_notification_storeid, item.getStoreKey());
                setText(itemView, R.id.list_item_notification_new_user,
                        getString(item.getIsNewVisitorInStore().booleanValue() ? R.string.yes : R.string.no));
                setText(itemView, R.id.list_item_notification_status, item.getStatus());
                setText(itemView, R.id.list_item_notification_session_start,
                        dateFormat.format(item.getInterval().getStart()));
                setText(itemView, R.id.list_item_notification_session_end,
                        dateFormat.format(item.getInterval().getEnd()));
                setText(itemView, R.id.list_item_notification_session_UUID, item.getUpdateUUID());
                return itemView;
            }
        };
        BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {

            private void displaySessionUpdate(PresenceSessionUpdate presenceSessionUpdate) {
                PresenceNotification notification = new PresenceNotification();
                notification.presenceSessionUpdate = presenceSessionUpdate;
                notification.received = new Date();
                presenceNotificationsListAdapter.insert(notification, 0);
                Log.i(LOG_TAG, "displaying session update|" + presenceSessionUpdate);
            }

            @Override
            public void onReceive(Context context, Intent intent) {
                String presenceSessionUpdateJson = intent.getStringExtra(
                        PresenceSessionUpdatesNotificationService.SESSION_UPDATE_JSON_PARAMETER);

                displaySessionUpdate(PresenceSessionUpdate.fromJson(presenceSessionUpdateJson));

            }
        };
        LocalBroadcastManager.getInstance(this).registerReceiver((broadcastReceiver),
                new IntentFilter(PresenceSessionUpdatesNotificationService.SESSION_UPDATE_INTENT_ID));
    }

}

From source file:jenkins.plugins.publish_over.BPBuildEnv.java

private String safeGetBuildTime() {
    if (buildTime == null)
        return null;
    try {//from   w  ww .j  a  va 2 s.  c om
        return DateFormat.getDateTimeInstance().format(buildTime.getTime());
    } catch (RuntimeException re) {
        return re.getLocalizedMessage();
    }
}

From source file:org.apache.myfaces.tomahawk.util.ErrorPageWriter.java

public static void debugHtml(Writer writer, FacesContext faces, Throwable e) throws IOException {
    init(faces);//  www  .j a  v a  2s.  co m
    Date now = new Date();
    for (int i = 0; i < ERROR_PARTS.length; i++) {
        if ("message".equals(ERROR_PARTS[i])) {
            String msg = e.getMessage();
            if (msg != null) {
                writer.write(msg.replaceAll("<", TS));
            } else {
                writer.write(e.getClass().getName());
            }
        } else if ("trace".equals(ERROR_PARTS[i])) {
            writeException(writer, e);
        } else if ("now".equals(ERROR_PARTS[i])) {
            writer.write(DateFormat.getDateTimeInstance().format(now));
        } else if ("tree".equals(ERROR_PARTS[i])) {
            if (faces.getViewRoot() != null) {
                writeComponent(writer, faces.getViewRoot(), getErrorId(e));
            }
        } else if ("vars".equals(ERROR_PARTS[i])) {
            writeVariables(writer, faces);
        } else if ("cause".equals(ERROR_PARTS[i])) {
            writeCause(writer, e);
        } else {
            writer.write(ERROR_PARTS[i]);
        }
    }
}

From source file:de.xwic.appkit.core.trace.impl.TraceDataManager.java

/**
 * @param traceContext/*from w  ww  . j  a va2s  .c o m*/
 */
private synchronized void logContext(ITraceContext tx, OutputStream out) {

    if (traceLogFile != null) {

        long start = tx.getStartTime();
        PrintWriter pw = new PrintWriter(out);
        pw.println("---------------------------------------------------------------------");
        pw.println("Start-Time: " + DateFormat.getDateTimeInstance().format(new Date(start)));
        pw.println("Total-Duration: " + tx.getDuration());
        if (tx.getName() != null) {
            pw.println("Name: " + tx.getName());
        }
        if (tx.getInfo() != null) {
            pw.println("Info: " + tx.getInfo());
        }
        pw.println("Attributes:");
        Map<String, String> attrs = tx.getAttributes();
        for (String key : attrs.keySet()) {
            pw.println("   " + key + "=" + attrs.get(key));
        }
        if (traceLevel != TraceLevel.BASIC) {
            pw.println();
            Map<String, ITraceCategory> catMap = tx.getTraceCategories();
            for (String cat : catMap.keySet()) {
                ITraceCategory category = catMap.get(cat);
                pw.println("[ " + cat + " (" + category.getCount() + " op(s) / " + category.getTotalDuration()
                        + "ms)]");
                if (traceLevel == TraceLevel.DETAILED) {
                    for (ITraceOperation op : category.getTraceOperations()) {
                        pw.println(String.format("# %s [start: %d; end: %d; total: %d ms]", op.getName(),
                                op.getStartTime() - start, op.getEndTime() - start, op.getDuration()));
                        if (op.getInfo() != null) {
                            pw.println(op.getInfo());
                        }
                    }
                }
            }

            List<StackTraceSnapShot> snapShots = tx.getStackTraceSnapShots();
            if (snapShots.size() > 0) {
                pw.println();
                pw.println("SnapShots taken:");
                StringBuilder sb = new StringBuilder();
                String previous = null;
                for (StackTraceSnapShot ss : snapShots) {
                    sb.setLength(0);
                    pw.println("StackTrace at " + (ss.getSnapShotTime() - start) + "ms");
                    for (StackTraceElement elm : ss.getStackTrace()) {
                        sb.append("  " + elm.getClassName() + "." + elm.getMethodName() + "(..):"
                                + elm.getLineNumber()).append("\n");
                    }
                    if (sb.toString().equals(previous)) {
                        pw.println("[ SAME AS PREVIOUS Stack Trace ]");
                    } else {
                        previous = sb.toString();
                        pw.print(previous);
                    }
                    pw.println("----");
                }
            }

        }
        pw.flush();

    } else {
        log.warn("Can not log trace details as no traceLogFile is defined.");
    }

}