1 28 29 package com.caucho.db.fun; 30 31 import com.caucho.db.sql.Expr; 32 import com.caucho.db.sql.FunExpr; 33 import com.caucho.db.sql.QueryContext; 34 import com.caucho.log.Log; 35 import com.caucho.util.Alarm; 36 import com.caucho.util.L10N; 37 import com.caucho.util.QDate; 38 39 import java.sql.SQLException ; 40 import java.util.Date ; 41 import java.util.logging.Logger ; 42 43 public class NowExpr extends FunExpr { 44 protected static final L10N L = new L10N(NowExpr.class); 45 private static final Logger log = Log.open(NowExpr.class); 46 47 protected void addArg(Expr expr) 48 throws SQLException 49 { 50 throw new SQLException (L.l("now() has no arguments")); 51 } 52 53 56 public Class getType() 57 { 58 return Date.class; 59 } 60 61 68 public boolean isNull(QueryContext context) 69 throws SQLException 70 { 71 return false; 72 } 73 74 81 public double evalDouble(QueryContext context) 82 throws SQLException 83 { 84 return evalLong(context); 85 } 86 87 94 public long evalLong(QueryContext context) 95 throws SQLException 96 { 97 return Alarm.getCurrentTime(); 98 } 99 100 107 public String evalString(QueryContext context) 108 throws SQLException 109 { 110 return QDate.formatLocal(evalLong(context)); 111 } 112 } 113 | Popular Tags |