// ==========================================================================
// $Id: TimeFormattable.java,v 1.1.1.1 2002/08/29 20:35:55 hitoshi Exp $
// Timer Formatable : interface of formator of timer 
// ==========================================================================
// Copyright (C) 2002 Yamauchi, Hitoshi
//
//   Max-Planck-Institut fuer Informatik AG4
//   Stuhlsatzenhausweg 85, 66123 Saarbruecken
//   http://www.mpi-sb.mpg.de/
// 
// This software can be redistributed only under GNU copyleft.
//
// @author Yamauchi Hitoshi »³Æâ ÀÆ
// ==========================================================================
// $Revision: 1.1.1.1 $
// $Date: 2002/08/29 20:35:55 $
// $Author: hitoshi $
// ==========================================================================
package de.mpg.mpisb.timerclock;

import  java.util.*;

public abstract class TimeFormattable
{
  /**
   * interface of format of time 
   *  timerep.length == 4, time representation as hour, minutes, seconds, millisec
   */
  public abstract String format(long t);

  /**
   * descriptions
   */
  public abstract String getDescription();

  /**
   * zero prefixed format 
   *  zeroP(1, 2) -> "01" zeroP(1, 3) -> "001"
   *
   *  @param value time value
   *  @param nDigits how many digits you want to show 
   *                 (the valid values are {0, 1, 2, 3}). 
   */
  public static String zeroP(long v, int nDigits)
  {
    if(nDigits > 3)
    {
      return(String.valueOf(v));
    }
    String out = "00".concat(String.valueOf(v));
    return(out.substring(out.length() - nDigits, out.length()));
  }
}
