formatting - Java Date issues -
I have a problem with the date of Java, when I pass in a Bile method before 1949. The date I have given back is for example 2049, I know that there is something to do with the date format and would be thought of using yyyy instead of RRRR. But I can not understand how and how to bring it. Any help will be more apreciated
public static java.sql.Date parseDate (string date) throws ParseException {if (date! = Null) {SimpleDateFormat dateFormat = New SimpleDateFormat ("dd-MMM- Yyyy "); New java.sql.Date Return (dateFormat.parse (date) .gettime ()); } Return tap; }
Thanks John
Let me give that format to you . .
Public static java.sql.Date parseDate (string date) throws ParseException {if (date! = Null) {SimpleDateFormat dateFormat = New SimpleDateFormat ("dd-MMM-yyyy"); New java.sql.Date Return (dateFormat.parse (date) .gettime ()); } Return tap; }I suspect what you want ...
private date converts () throws up ParseException {String dateStr = "21-02 -2010 "; SimpleDetform FormatDateformat = New Simple Data Format ("DD-MM-Yay"); Date date = null; If (dateStr! = Null) {date = new date (dateFormat.parse (dateStr) .getTime ()); } System.out.println (date); return date; }
For the 21-02-2010 you will find ... Feb 21, 00 00:00 GMT 2010
For the 21-02-1938 you will get ... Som 21 Feb. 00:00 GMT 1938
Does it help? I could have been in your code due to having MMM.
Comments
Post a Comment