package com.l7tech.security.xml.processor;

import com.l7tech.util.ISO8601Date;
import java.util.Date;
import org.w3c.dom.Element;

public class WssTimestampDateWrapper implements WssTimestampDate {
   private final WssTimestampDate a;
   private final Date b;
   private String c;

   public WssTimestampDateWrapper(WssTimestampDate var1) {
      this.a = var1;
      this.b = null;
   }

   public WssTimestampDateWrapper(WssTimestampDate var1, Date var2) {
      this.a = var1;
      this.b = var2;
   }

   @Override
   public long asTime() {
      return this.b != null ? this.b.getTime() : this.a.asTime();
   }

   @Override
   public String asIsoString() {
      if (this.b == null) {
         return this.a.asIsoString();
      }

      synchronized (this) {
         if (this.c == null) {
            this.c = ISO8601Date.format(this.b);
         }

         return this.c;
      }
   }

   @Override
   public Element asElement() {
      return this.a.asElement();
   }
}
