Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String[] value = date.split("-");
- String newDate = "";
- if (value.length > 2) newDate = value[2] + "/" + value[1] + "/" + value[2];
- public static void main(String[] args) {
- String value = "";
- System.out.println("value = " + value);
- System.out.println("result = " + value.replaceAll("(\d{2})/(\d{2})/(\d{4})", "$3-$2-$1"));
- value = "26/12/2014";
- System.out.println("value = " + value);
- System.out.println("result = " + value.replaceAll("(\d{2})/(\d{2})/(\d{4})", "$3-$2-$1"));
- }
- value =
- result =
- value = 26/12/2014
- result = 2014-12-26
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement