/** Initializes contained components. */
  private void initComponents() {
    final SimpleDateFormat format = new SimpleDateFormat("mm:ss");
    final Calendar c = Calendar.getInstance();
    final JLabel counter = new JLabel();

    counter.setForeground(Color.red);
    counter.setFont(counter.getFont().deriveFont((float) (counter.getFont().getSize() + 5)));

    setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

    GridBagConstraints constraints = new GridBagConstraints();

    JLabel messageLabel =
        new JLabel(
            GuiActivator.getResources().getI18NString("service.gui.security.SECURITY_ALERT"));

    messageLabel.setForeground(Color.WHITE);

    constraints.anchor = GridBagConstraints.CENTER;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 0;
    add(messageLabel, constraints);

    constraints.anchor = GridBagConstraints.CENTER;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 1;
    add(counter, constraints);

    ZrtpControl zrtpControl = null;
    if (securityControl instanceof ZrtpControl) zrtpControl = (ZrtpControl) securityControl;

    long initialSeconds = 0;

    if (zrtpControl != null) initialSeconds = zrtpControl.getTimeoutValue();

    c.setTimeInMillis(initialSeconds);

    counter.setText(format.format(c.getTime()));

    if (initialSeconds > 0)
      timer.schedule(
          new TimerTask() {
            @Override
            public void run() {
              if (c.getTimeInMillis() - 1000 > 0) {
                c.add(Calendar.SECOND, -1);
                counter.setText(format.format(c.getTime()));
              }
            }
          },
          1000,
          1000);
  }
 /** Returns the date the message was sent (or received if the sent date is null. */
 public String getDate() throws MessagingException {
   Date date;
   SimpleDateFormat df = new SimpleDateFormat("EE M/d/yy");
   if ((date = message.getSentDate()) != null) return (df.format(date));
   else if ((date = message.getReceivedDate()) != null) return (df.format(date));
   else return "";
 }
Exemple #3
0
  static void printResult(Calendar from, Calendar to) {
    Date fromDate = from.getTime();
    Date toDate = to.getTime();

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

    System.out.print(sdf.format(fromDate) + " ~ " + sdf.format(toDate) + ":");
    System.out.println(paycheckCount(from, to));
  }
Exemple #4
0
  public static void main(String[] av) {
    /** Today's date */
    Calendar now = Calendar.getInstance();

    /* Do "DateFormat" using "simple" format. */
    SimpleDateFormat formatter = new SimpleDateFormat("E yyyy/MM/dd 'at' hh:mm:ss a zzz");
    System.out.println("It is now " + formatter.format(now.getTime()));

    // Add a "# of years" increment to the existing Calendar object
    now.add(Calendar.YEAR, -2);

    System.out.println("Two years ago was " + formatter.format(now.getTime()));
  }
  void test2() {
    Locale defaultLocale = Locale.getDefault();
    TimeZone reservedTimeZone = TimeZone.getDefault();
    Date d = new Date(2005 - 1900, Calendar.DECEMBER, 22);
    String formatted;

    TimeZone tz;
    SimpleDateFormat df;

    try {
      for (int i = 0; i < TIMEZONES.length; i++) {
        tz = TimeZone.getTimeZone(TIMEZONES[i]);
        TimeZone.setDefault(tz);
        df = new SimpleDateFormat(pattern, DateFormatSymbols.getInstance(OSAKA));
        Locale.setDefault(defaultLocale);
        System.out.println(formatted = df.format(d));
        if (!formatted.equals(DISPLAY_NAMES_OSAKA[i])) {
          throw new RuntimeException(
              "TimeZone "
                  + TIMEZONES[i]
                  + ": formatted zone names mismatch. "
                  + formatted
                  + " should match with "
                  + DISPLAY_NAMES_OSAKA[i]);
        }

        df.parse(DISPLAY_NAMES_OSAKA[i]);

        Locale.setDefault(KYOTO);
        df = new SimpleDateFormat(pattern, DateFormatSymbols.getInstance());
        System.out.println(formatted = df.format(d));
        if (!formatted.equals(DISPLAY_NAMES_KYOTO[i])) {
          throw new RuntimeException(
              "Timezone "
                  + TIMEZONES[i]
                  + ": formatted zone names mismatch. "
                  + formatted
                  + " should match with "
                  + DISPLAY_NAMES_KYOTO[i]);
        }
        df.parse(DISPLAY_NAMES_KYOTO[i]);
      }
    } catch (ParseException pe) {
      throw new RuntimeException("parse error occured" + pe);
    } finally {
      // restore the reserved locale and time zone
      Locale.setDefault(defaultLocale);
      TimeZone.setDefault(reservedTimeZone);
    }
  }
Exemple #6
0
 /**
  * Generates a file name for the call based on the current date and the names of the peers in the
  * call.
  *
  * @param ext file extension
  * @return the file name for the call
  */
 private String generateCallFilename(String ext) {
   String filename = FORMAT.format(new Date()) + "-call";
   int maxLength = MAX_FILENAME_LENGTH - 2 - filename.length() - ext.length();
   String peerName = getCallPeerName(maxLength);
   filename += ((!peerName.equals("")) ? "-" : "") + peerName + "." + ext;
   return filename;
 }
 public String getPageContents() {
   StringBuffer buffer = new StringBuffer();
   SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd");
   buffer
       .append("== {{int:filedesc}} ==\n")
       .append("{{Information\n")
       .append("|description=")
       .append(description)
       .append("\n")
       .append("|source=")
       .append("{{own}}\n")
       .append("|author=[[User:"******"]]\n");
   if (dateCreated != null) {
     buffer
         .append("|date={{According to EXIF data|")
         .append(isoFormat.format(dateCreated))
         .append("}}\n");
   }
   buffer
       .append("}}")
       .append("\n")
       .append("== {{int:license-header}} ==\n")
       .append("{{self|cc-by-sa-3.0}}\n\n")
       .append("{{Uploaded from Mobile|platform=Android|version=")
       .append(CommonsApplication.APPLICATION_VERSION)
       .append("}}\n")
       .append("{{subst:unc}}"); // Remove when we have categorization
   return buffer.toString();
 }
  /** base constructer from a java.util.date object */
  public DERGeneralizedTime(Date time) {
    SimpleDateFormat dateF = new SimpleDateFormat("yyyyMMddHHmmss'Z'");

    dateF.setTimeZone(new SimpleTimeZone(0, "Z"));

    this.time = dateF.format(time);
  }
  /**
   * For the contracts whose volume shifts from the front contract to the back contract on the day
   * preceding the 2nd Friday of expiration month of the front contract.
   */
  public static String getMostLiquid(Calendar asOfDate) {

    int monthNow = asOfDate.get(Calendar.MONTH);
    int yearNow = asOfDate.get(Calendar.YEAR);
    int mostLiquidYear = yearNow;

    int mostLiquidMonth = frontMonths.get(monthNow);

    // special case with December
    if (monthNow == Calendar.DECEMBER) {
      mostLiquidYear = yearNow + 1;
    }

    if (keepCurrent(asOfDate)) {
      mostLiquidMonth = monthNow;
      mostLiquidYear = yearNow;
    }

    Calendar mostLiquidDate = Calendar.getInstance();
    mostLiquidDate.set(Calendar.DAY_OF_MONTH, 1);
    mostLiquidDate.set(Calendar.MONTH, mostLiquidMonth);
    mostLiquidDate.set(Calendar.YEAR, mostLiquidYear);

    SimpleDateFormat df = new SimpleDateFormat("yyyyMM");
    return df.format(mostLiquidDate.getTime());
  }
Exemple #10
0
 public static String getDateFormat(long lDate, String format) {
   String result = null;
   if (format != null) {
     SimpleDateFormat sdf = new SimpleDateFormat(format);
     result = sdf.format(lDate);
   }
   return result;
 }
Exemple #11
0
  /**
   * 현재날짜(System TimeZone 및 Locale 기준)에서 몇일 전,후의 날짜를 구한다.
   *
   * @param day 변경할 일수
   * @return 현재날짜에서 입력한 일수를 계산한 날짜(yyyyMMdd)
   */
  public static String getDateWithSpan(long day) {
    SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");

    java.util.Date date = new java.util.Date();
    java.util.Date spanDate = new java.util.Date(date.getTime() + (day * 1000 * 60 * 60 * 24));

    return fmt.format(spanDate);
  }
Exemple #12
0
  /**
   * 현재날짜를 dateType형식으로 보여준다. ForExample : yyyy yyyy-MM yyyy-MM-dd yyyyMMdd
   *
   * @param dateType
   * @return
   */
  public static String getCurrentDateByType(String dateType) {
    Calendar now = Calendar.getInstance();
    long lCurDate = now.getTimeInMillis();

    SimpleDateFormat sdf = new SimpleDateFormat(dateType);
    String sCurrentDate = sdf.format(lCurDate);

    return sCurrentDate;
  }
  /**
   * Returns the directory where the recording should be stored
   *
   * @return the directory of the new recording
   */
  String getRecordingDirectory() {
    if (this.recordingDirectory == null) {
      SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd.HH-mm-ss.");
      this.recordingDirectory =
          dateFormat.format(new Date()) + getID() + ((name != null) ? "_" + name : "");
    }

    return this.recordingDirectory;
  }
Exemple #14
0
  /**
   * Convert a date to required String format.
   *
   * @param date Given date.
   * @param format Given String ("dd-MM-yyyy" for 01-01-2000 format "dd-MMM-YYYY" for 01-Jan-2000
   *     format)
   * @return Date in required format.
   */
  public static String formatDateString(java.util.Date date, String format) {
    if ((date == null) || (format == null)) {
      return null;
    }

    // Set the date
    SimpleDateFormat fm = new SimpleDateFormat(format);
    return fm.format(date);
  }
Exemple #15
0
  // 현재날짜
  public static String getCurrentDate() {
    Calendar now = Calendar.getInstance();
    long lCurDate = now.getTimeInMillis();

    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
    String sCurrentDate = sdf.format(lCurDate);

    return sCurrentDate;
  }
Exemple #16
0
  public List<MersVO> mersData() {
    List<MersVO> list = new ArrayList<MersVO>();
    Date date = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d");
    StringTokenizer st = new StringTokenizer(sdf.format(date), "-");
    int year = Integer.parseInt(st.nextToken());
    int month = Integer.parseInt(st.nextToken());
    int day = Integer.parseInt(st.nextToken());
    try {
      Document doc = Jsoup.connect("http://www.cdc.go.kr/CDC/cms/content/15/63315_view.html").get();
      // System.out.println(doc);
      Elements trs = doc.select("table tbody tr");
      // System.out.println(trs);
      String data = "";
      String[] temp = {"panel panel-primary", "panel panel-green", "panel panel-yellow"};
      int i = 0;
      for (Element tr : trs) {
        Iterator<Element> it = tr.getElementsByTag("td").iterator();

        // if(i==2) break;
        while (it.hasNext()) {

          MersVO vo = new MersVO();
          vo.setType(it.next().text());
          vo.setMers(it.next().text().replace("*", ""));
          /*vo.setYsum(it.next().text().replace(",", ""));
          vo.setPlus(it.next().text());
          vo.setMinus(it.next().text());*/

          if (data.equals("")) {
            data = it.next().text();
            vo.setIng(data);
          } else {
            vo.setIng(data);
          }
          vo.setNsum(it.next().text().replace(",", ""));
          vo.setHouse(it.next().text());
          vo.setOffice(it.next().text());
          vo.setDis(it.next().text().replace(",", ""));
          vo.setDiv1(temp[i]);
          vo.setYear(year);
          vo.setMonth(month);
          if (i == 2) {
            vo.setDay(day - 1);
          } else {
            vo.setDay(day);
          }
          list.add(vo);
          i++;
        }
      }
    } catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
    return list;
  }
  public static void main(String[] args) throws ParseException {
    SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");

    List<OperatiuneContabila> operatiuni = new ArrayList<OperatiuneContabila>();
    operatiuni.add(new OperatiuneContabila(1, format.parse("01/06/2009")));
    operatiuni.add(new OperatiuneContabila(2, format.parse("01/03/2009")));
    operatiuni.add(new OperatiuneContabila(3, format.parse("01/02/2009")));
    operatiuni.add(new OperatiuneContabila(4, format.parse("01/04/2009")));

    Collections.sort(operatiuni, new ComparatorOperatiuniDupaData());
    System.out.println("Ordonare operatiuni dupa data :");
    for (OperatiuneContabila o : operatiuni)
      System.out.println(o.getIdOperatiune() + " -- " + format.format(o.getDataContabilizare()));

    Collections.sort(operatiuni, new ComparatorOperatiuniDupaId());
    System.out.println("Ordonare operatiuni dupa id :");
    for (OperatiuneContabila o : operatiuni)
      System.out.println(o.getIdOperatiune() + " -- " + format.format(o.getDataContabilizare()));
  }
  private void saveData(TelemetryData data) {
    PrintWriter out;
    boolean newFile = false;

    if (saveCnt > 25000) {
      File logFile;
      int i;

      logFile = new File(telemetryDir + 99 + ".log");
      logFile.delete();
      newFile = true;

      for (i = 99; i > 0; i--) {
        logFile = new File(telemetryDir + (i - 1) + ".log");
        logFile.renameTo(new File(telemetryDir + i + ".log"));
      }
      saveCnt = 0;
    }

    try {
      String text = "";
      SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.GERMAN);

      saveCnt++;
      out = new PrintWriter(new FileOutputStream(telemetryDir + "0.log", true));
      if (newFile) {
        text =
            "Time\tLatitude\tLongitude\tSpeed\tAcceleration X\tAcceleration Y\tAcceleration Z\tCoG\tOrientation Y\tOrientation Z\n\n";
        out.print(text);
      }
      text = dateFormat.format(new Date(System.currentTimeMillis())) + "\t";
      if (posValid) text = text + lastLat + "\t" + lastLon + "\t" + m_lastSpeed + "\t";
      else text = text + "-\t-\t-\t";
      text =
          text
              + data.getAccelX()
              + "\t"
              + data.getAccelY()
              + "\t"
              + data.getAccelZ()
              + "\t"
              + data.CoG
              + "\t"
              + data.getOrientY()
              + "\t"
              + data.getOrientZ()
              + "\n\n";
      out.print(text);
      out.close();
    } catch (IOException ioe) {
    }
  }
Exemple #19
0
 /**
  * Record a specific string
  *
  * @param s
  */
 public static void record(String s) {
   try {
     if (!recording) return;
     Date now = new Date();
     String ts = stamp.format(now);
     R.writeBytes(ts);
     R.writeBytes(" ");
     R.writeBytes(s);
     R.writeBytes("\n");
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
 public static boolean isValidDate(String dob) {
   SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
   Date testDate = null;
   try {
     testDate = sdf.parse(dob);
   } catch (ParseException e) {
     return false;
   }
   if (!sdf.format(testDate).equals(dob)) {
     return false;
   }
   return true;
 }
  // converts the XML date format to the SQL TIMESTAMP format
  // "Dec-03-01 18:38:23" => "0000-00-00 00:00:00"
  static String convertToSQLTime(String xmlTime) {
    SimpleDateFormat xmlFormat = new SimpleDateFormat("MMM-dd-yy HH:mm:ss");
    SimpleDateFormat sqlFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date inputDate = null;
    try {
      inputDate = xmlFormat.parse(xmlTime);
    } catch (ParseException pe) {
      System.out.println("ERROR: could not parse \"" + xmlTime + "\"");
      System.exit(3);
    }

    return sqlFormat.format(inputDate);
  }
Exemple #22
0
 /**
  * Start recording
  *
  * @param stub
  */
 public static void startRecorder(String stub) {
   try {
     stamp = new SimpleDateFormat("HH:mm:ss");
     SimpleDateFormat dateformat = new SimpleDateFormat("yyMMdd");
     Date d = new Date();
     String s = dateformat.format(d);
     String name = logdir + stub + s + ".txt";
     R = new RandomAccessFile(name, "rw");
     System.out.println("Log file: " + name);
     long N = R.length();
     R.seek(N);
     recording = true;
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
 public static String getDateTaken(File file) {
   Directory exifDirectory = getMetaDirectory(file);
   try {
     SimpleDateFormat formatter = new SimpleDateFormat("yyyy:MM:dd hh:mm:ss"); // original format
     if (exifDirectory != null) {
       String dateStr = exifDirectory.getString(ExifDirectory.TAG_DATETIME_ORIGINAL);
       Date date = formatter.parse(dateStr);
       formatter = new SimpleDateFormat("MM/dd/yyyy"); // desired format
       return formatter.format(date);
     }
     return "no date picture taken info";
   } catch (ParseException e) {
     e.printStackTrace();
   }
   return "error occurred while getting the date";
 }
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    String time = in.next();

    // Set format for input and output
    SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ssa");
    SimpleDateFormat out = new SimpleDateFormat("HH:mm:ss");

    try {
      Date inTime = sdf.parse(time);
      System.out.println(out.format(inTime));
    } catch (ParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  public void write(long time, Instrument instrument1, Instrument instrument2) {
    double bid1 = instrument1.getBid();
    double ask1 = instrument1.getAsk();
    double bid2 = instrument2.getBid();
    double ask2 = instrument2.getAsk();

    if (bid1 > 0 && ask1 > 0 && bid2 > 0 && ask2 > 0) {
      StringBuilder sb = new StringBuilder();
      sb.append(dateFormat.format(new Date(time))).append(",");
      sb.append(decimalFormat.format(bid1)).append(",");
      sb.append(decimalFormat.format(ask1)).append(",");
      sb.append(decimalFormat.format(bid2)).append(",");
      sb.append(decimalFormat.format(ask2));

      writer.println(sb);
      writer.flush();
    }
  }
Exemple #26
0
  public void testDateAdd() {
    assertEquals("2008/04/24 19:10:45", SAMPLE_DATE);

    // 2008-02-01 0:00:00
    Calendar calendar = Calendar.getInstance();

    calendar.set(2007, 1 /* 0-based! */, 1, 0, 0, 0);
    final Date feb2007 = calendar.getTime();
    assertEquals("2007/02/01 00:00:00", feb2007);

    assertEquals("2008/04/24 19:10:45", Vba.dateAdd("yyyy", 0, SAMPLE_DATE));
    assertEquals("2009/04/24 19:10:45", Vba.dateAdd("yyyy", 1, SAMPLE_DATE));
    assertEquals("2006/04/24 19:10:45", Vba.dateAdd("yyyy", -2, SAMPLE_DATE));
    // partial years interpolate
    final Date sampleDatePlusTwoPointFiveYears = Vba.dateAdd("yyyy", 2.5, SAMPLE_DATE);
    if (isPST) {
      // Only run test in PST, because test would produce different
      // results if start and end are not both in daylight savings time.
      final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.US);
      final String dateString = dateFormat.format(sampleDatePlusTwoPointFiveYears);
      // We allow "2010/10/24 07:10:45" for computers that have an out of
      // date timezone database. 2010/10/24 is in daylight savings time,
      // but was not according to the old rules.
      assertTrue(
          "Got " + dateString,
          dateString.equals("2010/10/24 06:40:45") || dateString.equals("2010/10/24 07:10:45"));
    }
    assertEquals("2009/01/24 19:10:45", Vba.dateAdd("q", 3, SAMPLE_DATE));

    // partial months are interesting!
    assertEquals("2008/06/24 19:10:45", Vba.dateAdd("m", 2, SAMPLE_DATE));
    assertEquals("2007/01/01 00:00:00", Vba.dateAdd("m", -1, feb2007));
    assertEquals("2007/03/01 00:00:00", Vba.dateAdd("m", 1, feb2007));
    assertEquals("2007/02/08 00:00:00", Vba.dateAdd("m", .25, feb2007));
    // feb 2008 is a leap month, so a quarter month is 7.25 days
    assertEquals("2008/02/08 06:00:00", Vba.dateAdd("m", 12.25, feb2007));

    assertEquals("2008/05/01 19:10:45", Vba.dateAdd("y", 7, SAMPLE_DATE));
    assertEquals("2008/05/02 01:10:45", Vba.dateAdd("y", 7.25, SAMPLE_DATE));
    assertEquals("2008/04/24 23:10:45", Vba.dateAdd("h", 4, SAMPLE_DATE));
    assertEquals("2008/04/24 20:00:45", Vba.dateAdd("n", 50, SAMPLE_DATE));
    assertEquals("2008/04/24 19:10:36", Vba.dateAdd("s", -9, SAMPLE_DATE));
  }
Exemple #27
0
  private void nextRaid(Info info) {
    GregorianCalendar nextRaid = raids.get(info.getChannel());
    GregorianCalendar now = Utils.getRealDate(info);
    int diffMins = (int) ((nextRaid.getTimeInMillis() - now.getTimeInMillis()) / 1000 / 60);
    if (nextRaid.compareTo(now) < 0) {
      info.sendMessage("There is no future raid set.");
      return;
    }
    String tz = info.getMessage().substring(9).trim();
    tz = substituteTimeZone(tz);
    TimeZone timeZone;
    if (tz.length() == 0) timeZone = tZF("GMT");
    else timeZone = tZF(tz);
    formatter.setTimeZone(timeZone);

    String ret = "The next raid is scheduled for " + formatter.format(nextRaid.getTime());
    ret = ret + getTimeDifference(diffMins);
    info.sendMessage(ret);
  }
 @Override
 public StringBuffer format(Date d, StringBuffer toAppendTo, FieldPosition pos) {
   /* delegate to SimpleDateFormat for easy stuff */
   super.format(d, toAppendTo, pos);
   /* worry aboutthe milliseconds ourselves */
   long millis = d.getTime() % 1000l;
   if (0L == millis) {
     return toAppendTo;
   }
   if (millis < 0L) {
     // original date was prior to epoch
     millis += 1000L;
   }
   int posBegin = toAppendTo.length();
   toAppendTo.append(millisFormat.format(millis / 1000d));
   if (DateFormat.MILLISECOND_FIELD == pos.getField()) {
     pos.setBeginIndex(posBegin);
     pos.setEndIndex(toAppendTo.length());
   }
   return toAppendTo;
 }
Exemple #29
0
 public static void load(String libDir, String mainClass, String[] args) throws Exception {
   Iterable<File> it = new FileIterator(libDir);
   List<URL> jars = new ArrayList<URL>();
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
   for (File f : it) {
     if (f.isDirectory()) {
       continue;
     }
     if (f.getName().toLowerCase().endsWith(".jar")) {
       System.out.println(
           "add " + f.getAbsolutePath() + " \t " + sdf.format(new Date(f.lastModified())));
       jars.add(f.toURI().toURL());
     }
   }
   System.out.println(
       "jar cnt=" + jars.size() + " run " + mainClass + " " + Arrays.deepToString(args));
   new URLClassLoader(jars.toArray(new URL[jars.size()]), Loader.class.getClassLoader())
       .loadClass(mainClass)
       .getMethod("main", new Class[] {String[].class})
       .invoke(null, new Object[] {args});
 }
Exemple #30
0
  public String _tstamp(String args[]) {
    String format = "yyyyMMddHHmm";
    long now = System.currentTimeMillis();
    TimeZone tz = TimeZone.getTimeZone("UTC");

    if (args.length > 1) {
      format = args[1];
    }
    if (args.length > 2) {
      tz = TimeZone.getTimeZone(args[2]);
    }
    if (args.length > 3) {
      now = Long.parseLong(args[3]);
    }
    if (args.length > 4) {
      domain.warning("Too many arguments for tstamp: " + Arrays.toString(args));
    }

    SimpleDateFormat sdf = new SimpleDateFormat(format);
    sdf.setTimeZone(tz);

    return sdf.format(new Date(now));
  }