In this particular case, I'm not sure I agree that your edit is a good one.
Yes, code should be put in a code block. But the author's original version showed the full answer directly to the reader. Your edit requires horizontal scrolling. I would have been annoyed with such an edit, if it had been an answer I had written.
That said, rolling it back was also not the right thing to do, especially without a comment. Both you and the OP should have edited, and didn't edit, the answer in such a way that the edit clearly was a clear improvement, not something that improves one aspect of the answer and hurts another.
The OP's version, hard to read:
SimpleDateFormat s = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss", Locale.getDefault());
String dateFormat = s.format(new Date(System.currentTimeMillis()));
Your edit, still a bit unnecessarily hard to read:
SimpleDateFormat s = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss", Locale.getDefault());
String dateFormat = s.format(new Date(System.currentTimeMillis()));
One of the possible approaches to make it easy to read:
SimpleDateFormat s = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss",
Locale.getDefault());
String dateFormat = s.format(new Date(System.currentTimeMillis()));
And another:
SimpleDateFormat s = new SimpleDateFormat(
"dd/MM/yyyy hh:mm:ss",
Locale.getDefault()
);
String dateFormat = s.format(new Date(
System.currentTimeMillis()
));
Both of these avoid horizontal scrolling. In the latter, System.currentTimeMillis
is only on its own line for symmetry with the surrounding code.
code tics
" rages just make me sigh...