CurrencyFormat.java 860 Bytes
Newer Older
Luis Gangas committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
package trismegistoplanilla.utilities;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class CurrencyFormat {

  public static String getCustomCurrency(double currency) {
    BigDecimal cc = new BigDecimal(currency);
    return cc.setScale(2, RoundingMode.HALF_UP).toString();
  }

  /**
   * Método que retorna la fecha actual enviando como parámetro el formato
   * deseado.
   *
   * @param format Formato deseado para la fecha actual
   * @return Fecha actual
   */
  public static String getActualDate(String format) {
    DateFormat dateFormat = new SimpleDateFormat(format);
    Date date = new Date();
    return dateFormat.format(date);
  }
  

  public static void main(String[] args) {
    String fecha = "14/05/2018 09:01:20 a.m.";
  }
}