Skip to content

Instantly share code, notes, and snippets.

@mjg123
Created February 22, 2021 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjg123/3b3c8fa8b2a82ff3aa2ae0602fcda4d8 to your computer and use it in GitHub Desktop.
Save mjg123/3b3c8fa8b2a82ff3aa2ae0602fcda4d8 to your computer and use it in GitHub Desktop.
public String messageBuilder(Price price, String symbol) {
return String.format("Here are the most up-to-date %s prices:\n" +
"\uD83C\uDF05 Open price of the day: $%s\n" +
"\uD83D\uDCC8 High price of the day: $%s\n" +
"\uD83D\uDCC9 Low price of the day: $%s\n" +
"\uD83D\uDD14 Current price: $%s\n" +
"\uD83D\uDCC6 Previous close price: $%s\n" +
"\uD83E\uDD1E Send another symbol.",
symbol, price.open, price.high, price.low, price.current, price.close);
}
@mjg123
Copy link
Author

mjg123 commented Feb 25, 2021

OMG I just learned this:
if you put <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> into the <properties> section of pom.xml you can write your code like this:

    public String messageBuilder(Price price, String symbol) {
        return String.format("Here are the most up-to-date %s prices:\n" +
               "πŸŒ… Open price of the day: $%s\n" +
               "πŸ“ˆ High price of the day: $%s\n" +
               "πŸ“‰ Low price of the day: $%s\n" +
               "πŸ”” Current price: $%s\n" +
               "πŸ“† Previous close price: $%s\n" +
               "🀞 Send another symbol.",
            symbol, price.open, price.high, price.low, price.current, price.close);
    }

(if you're trying to copy-paste emoji into IntelliJ you might need to use ctrl-shift-v to paste without formatting, but it works)

@Eclairemoy
Copy link

omg this is so cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment