Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. String[] value = date.split("-");
  2. String newDate = "";
  3. if (value.length > 2) newDate = value[2] + "/" + value[1] + "/" + value[2];
  4.  
  5. public static void main(String[] args) {
  6. String value = "";
  7. System.out.println("value = " + value);
  8. System.out.println("result = " + value.replaceAll("(\d{2})/(\d{2})/(\d{4})", "$3-$2-$1"));
  9. value = "26/12/2014";
  10. System.out.println("value = " + value);
  11. System.out.println("result = " + value.replaceAll("(\d{2})/(\d{2})/(\d{4})", "$3-$2-$1"));
  12. }
  13.  
  14. value =
  15. result =
  16. value = 26/12/2014
  17. result = 2014-12-26
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement