Modified the dateformat retrieved by the Java routine 'DirList' (MIP_DIRLIST.jsp). Previous version would generate an ORA-1850 when viewing files with a file modified time during the midnight hour.
git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@16885 248e525c-4dfb-0310-94bc-949c084e9493
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED DirList AS
|
create or replace and compile java source named dirlist as
|
||||||
|
//
|
||||||
|
//$Id$
|
||||||
|
//
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
|
|
||||||
public class DirList
|
public class DirList
|
||||||
{
|
{
|
||||||
public static void getList(String directory)
|
public static void getList(String directory)
|
||||||
@@ -13,42 +16,54 @@ import java.text.SimpleDateFormat;
|
|||||||
File path = new File( directory );
|
File path = new File( directory );
|
||||||
String[] list = path.list();
|
String[] list = path.list();
|
||||||
String element;
|
String element;
|
||||||
|
|
||||||
for(int i = 0; i < list.length; i++)
|
for(int i = 0; i < list.length; i++)
|
||||||
{
|
{
|
||||||
element = list[i];
|
element = list[i];
|
||||||
|
|
||||||
|
|
||||||
String fpath=directory+"/"+list[i];
|
String fpath=directory+"/"+list[i];
|
||||||
|
|
||||||
File f = new File(fpath);
|
File f = new File(fpath);
|
||||||
|
|
||||||
long len;
|
long len;
|
||||||
Date date;
|
Date date;
|
||||||
|
|
||||||
String ftype;
|
String ftype;
|
||||||
String sqldate;
|
String sqldate;
|
||||||
|
//
|
||||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss");
|
// ref: http://javatechniques.com/blog/dateformat-and-simpledateformat-examples/
|
||||||
|
//
|
||||||
|
// for date of 3rd January 2010, 23:05:09
|
||||||
|
// y = year: yyyy = 2010
|
||||||
|
// M = month number: MM = 01
|
||||||
|
// d = day in month: dd = 03
|
||||||
|
// H = Hour (0-23): HH = 23
|
||||||
|
// m = minute: mm = 05
|
||||||
|
// s = second: ss = 09
|
||||||
|
//
|
||||||
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
if (f.isFile()) {
|
if (f.isFile()) {
|
||||||
|
|
||||||
len = f.length();
|
len = f.length();
|
||||||
|
|
||||||
date = new Date(f.lastModified());
|
date = new Date(f.lastModified());
|
||||||
sqldate = df.format(date) ;
|
sqldate = df.format(date) ;
|
||||||
|
|
||||||
ftype = "F";
|
ftype = "F";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
len = 0;
|
len = 0;
|
||||||
sqldate = null;
|
sqldate = null;
|
||||||
ftype = "D";
|
ftype = "D";
|
||||||
}
|
}
|
||||||
|
|
||||||
#sql { INSERT INTO GTT_DIR_LIST (FILENAME, filelength, filetype, filemodified)
|
#sql { INSERT INTO GTT_DIR_LIST (FILENAME, filelength, filetype, filemodified)
|
||||||
VALUES (:element, :len, :ftype, to_date(:sqldate,'YYYY-MM-DD HH24:MI:SS')) };
|
VALUES (:element, :len, :ftype, to_date(:sqldate,'YYYY-MM-DD HH24:MI:SS')) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/
|
/
|
||||||
|
|||||||
Reference in New Issue
Block a user