Created
January 24, 2020 15:11
-
-
Save neilsonlima/de801fbedb01b5e534ad6484f287d98e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExFormatationDate { | |
public static void main(String[] args) { | |
String dt1 = "20200124"; | |
StringBuilder sb = new StringBuilder(dt1) | |
.insert(4,"-") | |
.insert(7,"-"); | |
String output = sb.toString(); | |
System.out.println(output); | |
String dt2 = "20200124"; | |
String dataf = dt2.replaceAll("(\\d{4})(\\d{2})(\\d{2})", "$1-$2-$3"); | |
System.out.println(dataf); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment