Formatter.java

  1. /* Contributed in the public domain.
  2.  * Licensed to CS GROUP (CS) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * CS licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.orekit.utils;

  18. import java.util.Locale;

  19. /** Formatter used to produce strings from data.
  20.  * <p>
  21.  * Interface for formatters to be passed to generators, dictating how to write doubles and datetime.
  22.  * </p>
  23.  * @author John Ajamian
  24.  * @since 13.0
  25.  */
  26. public interface Formatter {

  27.     /**
  28.      * Standardized locale to use, to ensure files can be exchanged without
  29.      * internationalization issues.
  30.      */
  31.     Locale STANDARDIZED_LOCALE = Locale.US;

  32.     /** String format used for dates. **/
  33.     String DATE_FORMAT = "%04d-%02d-%02dT%02d:%02d:%s";

  34.     /**
  35.      * Format a double number.
  36.      *
  37.      * @param value number to format
  38.      * @return number formatted.
  39.      */
  40.     String toString(double value);

  41.     /** Format a date. Does not check if date time is real or if it will meet formating requirements.
  42.      * @param year of date to be formatted
  43.      * @param month of date to be formatted
  44.      * @param day of month to be formatted
  45.      * @param hour to be formatted
  46.      * @param minute to be formatted
  47.      * @param seconds and sub-seconds to be formatted
  48.      * @return date formatted to match the following format [yyyy-MM-ddTHH:mm:ss.S#]
  49.      */
  50.     String toString(int year, int month, int day, int hour, int minute, double seconds);

  51. }