2010年7月22日 星期四

Time

1. In the java you can use

{{{
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); //yyyy-MM-dd HH:mm:ss Z//
Date jobSubmitTime = null;
Date nowTime = new Date();
long timeDifferent = 0;

// Get the job
try {
while (sourceJobIterator.hasNext()) {
logger.info("Enter the resubmit job loop. ");

RecordExpr job = (RecordExpr) sourceJobIterator.next();
logger.info("2");

String jobTime = (new GapJDLParser(job)).getSubmissionTime();
//String jobTime = (new GapJDLParser(job)).get;
logger.info("3");

jobSubmitTime = df.parse(jobTime);

logger.info("4");
logger.info("job: " + (new GapJDLParser(job)).getJobId()
+ ", submit Time: " + jobSubmitTime.getTime()
+ ", current Time: " + nowTime.getTime());


timeDifferent = (nowTime.getTime() - jobSubmitTime.getTime()) / SECONDS_IN_MILLION;
}}}


2. but in sql
{{{
String query = "SELECT b.name,b.vo,b.lsa_host,b.lsa_type,b.lsa_pid,";
query += "b.appid,b.tag,b.nprocs,b.status,";
query += "b.id as jid,b.sub_id,b.qpriority,b.outputs,b.inputs,";
query += "to_char(b.sub_dtime, 'YYYY-MM-DD HH24:MI:SS TZ') as sub_dtime,";
query += "to_char(b.run_dtime, 'YYYY-MM-DD HH24:MI:SS TZ') as run_dtime,";
query += "to_char(b.done_dtime, 'YYYY-MM-DD HH24:MI:SS TZ') as done_dtime,";
query += "b.timeout,b.trial_count,b.retry_reason,";
query += "b.share_user,b.share_vo,b.share_role,";
query += "a.dn as dn,a.email FROM ";
query += "udb_user as a, jdb_jlist as b, udb_gproxy as c ";
query += "WHERE b.id=? AND b.sub_id=? AND a.dn=b.dn";
}}}

SQL: becareful the time is the automatic build
{{{
CREATE TABLE jdb_jgroup (
id character(256) NOT NULL,
dn character(256) NOT NULL,
vo character(32) NOT NULL REFERENCES vo_list(vo),
adv_appid character(32) NOT NULL,
command_name character(256),
status character(32) NOT NULL,
sub_dtime timestamp with time zone DEFAULT now() NOT NULL,
description text,
command_fqcn character(256) NOT NULL,
success_rate double precision DEFAULT 0.0 NOT NULL,
job_count integer DEFAULT 1 NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (dn) REFERENCES udb_user(dn) ON UPDATE CASCADE ON DELETE CASCADE
);
}}}

沒有留言:

張貼留言