May 17, 2002 #1 natncm70 MIS Jan 16, 2002 66 IN Hello, I am having a String Variable with Date Format. I need to convert that String Variable to Date.What should i do for that? Please Help me Regards
Hello, I am having a String Variable with Date Format. I need to convert that String Variable to Date.What should i do for that? Please Help me Regards
May 17, 2002 #2 DeSn Programmer Nov 20, 2001 111 BE Use the java.text.SimpleDateFormat class you can supply a format to that class and then use the parse(string) function eg in pseudo code: java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("dd/MM/yyyy" formatter.parse( string here); this gives you a java.util.Date if you need a java.sql.date just do new java.sql.date(java.util.Date.getTime()) Upvote 0 Downvote
Use the java.text.SimpleDateFormat class you can supply a format to that class and then use the parse(string) function eg in pseudo code: java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("dd/MM/yyyy" formatter.parse( string here); this gives you a java.util.Date if you need a java.sql.date just do new java.sql.date(java.util.Date.getTime())