Original Source Code
- http://taapps-sourcecode-libraries.googlegroups.com/web/Dat.java
- Description
This function is a converter from Date object to String.This function works like ORACLE PL/SQL's to_char function.
Dat.convertDateToStr method has 2 arguments, one is a Date format you want to convert, other is a Data format String object like "yyyy/MM/dd". - Sample
Output Date object to String changed format like "2007/12/31 12:00:00".
This function works like ORACLE PL/SQL's to_date function.java.util.Date testDate=new java.util.Date();
.......
System.out.println("Date Output:"+Dat.convertDateToStr(testDate,"yyyy/MM/dd HH:mm:ss"));
- Description
This function is a converter from String object to Date object.This function works like ORACLE PL/SQL's to_date function.
Dat.convertStrToDate method has 2 arguments, one is a String object including date, other is a Date format String. - Sample
String testDateStr="2007/12/31";
....
java.util.Date convertedDate=Dat.convertStrToDate(testDateStr,"yyyy/MM/dd");
- Description
You sometimes need to get long value between 2 Date objects(for example, you need to get execution time when debugging the program and checking performance).
Dat.getDateDiff method has 3 arguments and returns the difference long value between 2 Date object. one argument is a first Date object, second argument is a Date object, third argument is a boolean type argument to convert the result long value to absolute value. - Sample
java.util.Date date1=Dat.convertStrToDate("2007/12/31","yyyy/MM/dd");
..........
java.util.Date date2=Dat.convertStrToDate("1973/12/31","yyyy/MM/dd");
..........
long dateDiff=Dat.getDateDiff(date1,date2,false);
0 件のコメント:
コメントを投稿