DEV Community

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

Collapse
 
elmuerte profile image
Michiel Hendriks • Edited

I google "java string format" every time I need to do more than just %s or %d.

I google a shit load of stuff. Although often limited to specific sites because I know the answer is within that site.

As Einstein said:

"Never memorize something that you can look up."

In the office I'm known as a person who knows a lot of stuff, especially related to the software we build. At some point a colleague came up to me: "How do X in SQL for Postgres?". So I got my browser and searched for X on site:postgresql.org . "I could have done that." the colleague responded, to which I replied "You think I'd bother to remember trivial stuff like this which are just a small search away?"

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.