Here you can find the source of formatToDate(String date)
public static final String formatToDate(String date)
//package com.java2s; public class Main { public static final String formatToDate(String date) { if (date == null) { return ""; } else {//w w w . j a v a 2 s . c o m int index = date.indexOf(" "); return (index > 0 ? date.substring(0, index) : date) .replaceAll("/", "-"); } } }