1 5 6 package com.raptus.owxv3.api.components; 7 8 import java.text.*; 9 import java.util.*; 10 11 import javax.servlet.http.HttpServletRequest ; 12 13 import org.apache.struts.action.ActionMapping; 14 15 import com.raptus.owxv3.LoggingManager; 16 17 39 public class CmpEntryBean extends ComponentBean 40 { 41 42 45 protected boolean flagEntryDte = false; 46 47 50 protected boolean flagTimedPub = false; 51 52 55 protected String entryDte = null; 56 57 60 protected String showFromDate = null; 61 protected String showFromTime = null; 62 63 66 protected String showUntilDate = null; 67 protected String showUntilTime = null; 68 69 70 72 75 public boolean getFlagEntryDte() { return flagEntryDte; } 76 public void setFlagEntryDte(boolean flag) 77 { 78 80 this.flagEntryDte = flag; 81 } 82 83 86 public boolean getFlagTimedPub() { return flagTimedPub; } 87 public void setFlagTimedPub(boolean tpub) 88 { 89 91 this.flagTimedPub = tpub; 92 93 } 94 95 98 public String getEntryDte() { return entryDte; } 99 public void setEntryDte(String dte) 100 { 101 this.entryDte = dte; 104 } 105 106 109 public String getShowFromDate() { return showFromDate; } 110 public void setShowFromDate(String dte) 111 { 112 this.showFromDate = dte; 115 } 116 117 120 public String getShowFromTime() { return showFromTime; } 121 public void setShowFromTime(String tme) 122 { 123 this.showFromTime = tme; 126 } 127 128 131 public String getShowUntilDate() { return showUntilDate; } 132 public void setShowUntilDate(String dte) 133 { 134 this.showUntilDate = dte; 137 } 138 139 142 public String getShowUntilTime() { return showUntilTime; } 143 public void setShowUntilTime(String tme) 144 { 145 148 this.showUntilTime = tme; 149 } 150 151 161 public java.util.Date getShowFrom() 162 { 163 if(showFromDate != null) showFromDate = showFromDate.trim(); 164 if(showFromTime != null) showFromTime = showFromTime.trim(); 165 166 if(showFromDate == null || showFromDate.length() == 0) 167 { 168 flagTimedPub = false; 169 return null; 170 } 171 172 if(showFromTime == null || showFromTime.length() == 0) 173 showFromTime = getLocalizedTime("00:00"); 174 175 return getDateObj(showFromDate + " " + showFromTime); 176 } 177 178 188 public java.util.Date getShowUntil() 189 { 190 if(showUntilDate != null) showUntilDate = showUntilDate.trim(); 191 if(showUntilTime != null) showUntilTime = showUntilTime.trim(); 192 193 if(showUntilDate == null || showUntilDate.length() == 0) 194 return null; 195 196 if(showUntilTime == null || showUntilTime.length() == 0) 197 showUntilTime = getLocalizedTime("23:59"); 198 199 return getDateObj(showUntilDate + " " + showUntilTime); 200 } 201 202 213 protected String getLocalizedTime(String s) 214 { 215 DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT, new Locale("de", "CH")); 216 Date c = null; 217 try 218 { 219 c = df.parse(s); 220 } 221 catch(ParseException e) { 222 return s; 223 } 224 225 df = DateFormat.getTimeInstance(DateFormat.SHORT, currLocale); 226 return df.format(c); 227 } 228 229 246 protected java.util.Date getDateObj(String s) 247 { 248 java.util.Date dval = null; 249 DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, 250 DateFormat.SHORT, currLocale); 251 try 252 { 253 dval = df.parse(s); 254 } 255 catch(ParseException e) { 256 LoggingManager.log("ParseException while trying to convert. " + e.getMessage(), this); 257 return dval; 258 } 259 260 return dval; 261 } 262 263 266 public void reset(ActionMapping mapping, HttpServletRequest request) 267 { 268 super.reset(mapping, request); 269 flagEntryDte = false; 270 flagTimedPub = false; 271 } 273 274 282 } 283 284 | Popular Tags |