I get the '-' is the left align but what is the period('.') in between?
I'm also seeing a lot of #impliedDecimal7SignLastTwoZero. I read that "Implied decimal simply means there is a decimal point implied at a specified location in a field, but not actually present in the file", but I dont get the "7SignLastTwoZero" portion.
%-8.8s
To get a first understanding let’s try it out:
Output is:
As you said
%-8s
would print output left-justified in 8 positions. Except: if the output is longer than 8 chars, it is printed in as many positions as needed. This is where the extra.8
makes a difference: it truncates the output to at most 8 positions as you see in the third line above. It’s in the documentation:You added:
In this case I’d warn against
%-8.8s
. If by some mistake there is a 9 or 10 digit ID, no one will discover because the formatting tacitly truncates to 8 digits. Better to either print all the digits so we can see them, or report an error in some way.%1$tY%1$tm%1$td
This format string prints year, month and day of month from argument 1 to the format method.
1$
means the first argument after the format string.t
means date and/or time, andY
,m
andd
the different parts of a date. So the output meant year 2020, January 29. All of this too is documented:I have quoted only the 3 relevant entries from the last table, there are many more letters.
Edit: BTW it may be clearer to obtain the latter result in this way:
Midnight has passed in Kirov since I first posted this answer, so now the output us:
Documentation link
Documentation of Java format strings