Here you can find the source of stringToDate(String strDate, String oracleFormat)
@SuppressWarnings("unchecked") public static Date stringToDate(String strDate, String oracleFormat)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.*; public class Main { @SuppressWarnings("unchecked") public static Date stringToDate(String strDate, String oracleFormat) { if (strDate == null) return null; Hashtable h = new Hashtable(); String javaFormat = ""; String s = oracleFormat.toLowerCase(); if (s.indexOf("yyyy") != -1) h.put(new Integer(s.indexOf("yyyy")), "yyyy"); else if (s.indexOf("yy") != -1) h.put(new Integer(s.indexOf("yy")), "yy"); if (s.indexOf("mm") != -1) h.put(new Integer(s.indexOf("mm")), "MM"); if (s.indexOf("dd") != -1) h.put(new Integer(s.indexOf("dd")), "dd"); if (s.indexOf("hh24") != -1) h.put(new Integer(s.indexOf("hh24")), "HH"); if (s.indexOf("mi") != -1) h.put(new Integer(s.indexOf("mi")), "mm"); if (s.indexOf("ss") != -1) h.put(new Integer(s.indexOf("ss")), "ss"); for (int intStart = 0; s.indexOf("-", intStart) != -1; intStart++) { intStart = s.indexOf("-", intStart); h.put(new Integer(intStart), "-"); }/* ww w. j a v a 2 s. c om*/ for (int intStart = 0; s.indexOf("/", intStart) != -1; intStart++) { intStart = s.indexOf("/", intStart); h.put(new Integer(intStart), "/"); } for (int intStart = 0; s.indexOf(" ", intStart) != -1; intStart++) { intStart = s.indexOf(" ", intStart); h.put(new Integer(intStart), " "); } for (int intStart = 0; s.indexOf(":", intStart) != -1; intStart++) { intStart = s.indexOf(":", intStart); h.put(new Integer(intStart), ":"); } if (s.indexOf("/u5E74") != -1) h.put(new Integer(s.indexOf("/u5E74")), "/u5E74"); if (s.indexOf("/u6708") != -1) h.put(new Integer(s.indexOf("/u6708")), "/u6708"); if (s.indexOf("/u65E5") != -1) h.put(new Integer(s.indexOf("/u65E5")), "/u65E5"); if (s.indexOf("/u65F6") != -1) h.put(new Integer(s.indexOf("/u65F6")), "/u65F6"); if (s.indexOf("/u5206") != -1) h.put(new Integer(s.indexOf("/u5206")), "/u5206"); if (s.indexOf("/u79D2") != -1) h.put(new Integer(s.indexOf("/u79D2")), "/u79D2"); int i = 0; while (h.size() != 0) { Enumeration e = h.keys(); int n = 0; while (e.hasMoreElements()) { i = ((Integer) e.nextElement()).intValue(); if (i >= n) n = i; } String temp = (String) h.get(new Integer(n)); h.remove(new Integer(n)); javaFormat = temp + javaFormat; } SimpleDateFormat df = new SimpleDateFormat(javaFormat); Date myDate = new Date(); try { myDate = df.parse(strDate); } catch (Exception e) { return null; } return myDate; } }