Skip to content

Instantly share code, notes, and snippets.

@juanpabloprado
Last active April 27, 2019 22:04
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 juanpabloprado/a7a13358dbefa3e195cfe94381767888 to your computer and use it in GitHub Desktop.
Save juanpabloprado/a7a13358dbefa3e195cfe94381767888 to your computer and use it in GitHub Desktop.
Specialized Formatters on the Java Shell tool
jshell> LocalDateTime ldt = LocalDateTime.now();
ldt ==> 2019-04-27T16:56:46.267683
jshell> String dateTime = ldt.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
dateTime ==> "20190427"
jshell> import java.nio.file.Path;
jshell> import java.nio.file.Paths;
jshell> Path target = Paths.get("app_props_" + dateTime + ".properties");
target ==> app_props_20190427.properties
jshell> import java.nio.file.Files;
jshell> Files.createFile(target).getFileName();
$95 ==> app_props_20190427.properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment