1 21 22 package org.apache.derby.impl.sql.execute; 23 24 27 import java.sql.Date ; 28 import java.sql.Time ; 29 import java.sql.Timestamp ; 30 31 45 public class CurrentDatetime { 46 47 51 private java.util.Date currentDatetime; 52 55 private Date currentDate; 56 59 private Time currentTime; 60 63 private Timestamp currentTimestamp; 64 65 69 public CurrentDatetime() { 70 } 71 72 final private void setCurrentDatetime() { 74 if (currentDatetime == null) 75 currentDatetime = new java.util.Date (); 76 } 77 78 80 public Date getCurrentDate() { 81 if (currentDate == null) { 82 setCurrentDatetime(); 83 currentDate = new Date (currentDatetime.getTime()); 84 } 85 return currentDate; 86 } 87 88 public Time getCurrentTime() { 89 if (currentTime == null) { 90 setCurrentDatetime(); 91 currentTime = new Time (currentDatetime.getTime()); 92 } 93 return currentTime; 94 } 95 96 public Timestamp getCurrentTimestamp() { 97 if (currentTimestamp == null) { 98 setCurrentDatetime(); 99 currentTimestamp = new Timestamp (currentDatetime.getTime()); 100 } 101 return currentTimestamp; 102 } 103 104 108 public void forget() { 109 currentDatetime = null; 110 currentDate = null; 111 currentTime = null; 112 currentTimestamp = null; 113 } 114 115 } 116 | Popular Tags |