DEV Community

Discussion on: Are you a fake developer? Me too.

Collapse
 
badrecordlength profile image
Henry 👨‍💻

As the author of the original post, I can confirm that I used to have to google that all the time too hahahaha. Think I have it committed to memory now though.

Collapse
 
elmuerte profile image
Michiel Hendriks

Ok, quick test. Format the date passed in the 2nd argument into 4 digit year, and 24 hour clock followed by a left padding of the 1st argument with spaces up to a minimum length of 8.

Thread Thread
 
badrecordlength profile image
Henry 👨‍💻 • Edited

Ok, firstly I have to admit I did some googling (I meant that I'd memorised how to format strings and decimals to different decimal places haha) but, this?

LocalDate date = LocalDate.now();
LocalTime time = LocalTime.now();
System.out.println(String.format("%8tR %tY", time, date));

I guess I am a fake developer after all.

Thread Thread
 
elmuerte profile image
Michiel Hendriks

I actually meant this

String.format("%2$tY%2$tR%1$8s", "dev.to", new Date())

Yes I googled the documentation.

Thread Thread
 
badrecordlength profile image
Henry 👨‍💻

Ah I see, makes sense, sorry I got a little confused by the wording.