Home | History | Annotate | Download | only in duration
      1 //  2016 and later: Unicode, Inc. and others.
      2 // License & terms of use: http://www.unicode.org/copyright.html#License
      3 /*
      4 ******************************************************************************
      5 * Copyright (C) 2007, International Business Machines Corporation and   *
      6 * others. All Rights Reserved.                                               *
      7 ******************************************************************************
      8 */
      9 
     10 package com.ibm.icu.impl.duration;
     11 
     12 import java.util.Date;
     13 import java.util.TimeZone;
     14 
     15 /**
     16  * Abstract formatter for dates.  Differs from DateFormat in that it
     17  * provides <code>withLocale</code> and <code>withTimeZone</code> methods.
     18  */
     19 public interface DateFormatter {
     20 
     21   /**
     22    * Format the date, provided as a java Date object.
     23    *
     24    * @param date the date
     25    * @return the formatted time
     26    */
     27   String format(Date date);
     28 
     29   /**
     30    * Format the date, provided as milliseconds.
     31    *
     32    * @param date the date in milliseconds
     33    * @return the formatted time
     34    */
     35   String format(long date);
     36 
     37   /**
     38    * Returns a new DateFormatter that uses data for a new locale.
     39    *
     40    * @param locale the new locale to use
     41    * @return a new formatter for the given locale
     42    */
     43   DateFormatter withLocale(String localeName);
     44 
     45   /**
     46    * Returns a new DateFormatter that uses the new time zone.
     47    *
     48    * @param tz the new time zone
     49    * @return a new formatter for the given time zone
     50    */
     51   DateFormatter withTimeZone(TimeZone tz);
     52 }
     53