Example usage for java.text NumberFormat setMinimumIntegerDigits

List of usage examples for java.text NumberFormat setMinimumIntegerDigits

Introduction

In this page you can find the example usage for java.text NumberFormat setMinimumIntegerDigits.

Prototype

public void setMinimumIntegerDigits(int newValue) 

Source Link

Document

Sets the minimum number of digits allowed in the integer portion of a number.

Usage

From source file:org.mycore.datamodel.ifs.MCRAudioVideoExtender.java

/**
 * Returns the framerate formatted as a String, e. g. "25.0"
 * /*from w  w  w  . j  a  va 2  s .c o m*/
 * @return the framerate formatted as a String, e. g. "25.0"
 */
public String getFrameRateFormatted() {
    // double r = (double)( Math.round( frameRate * 10.0 ) ) / 10.0;
    NumberFormat formatter = NumberFormat.getInstance(Locale.ROOT);
    formatter.setGroupingUsed(false);
    formatter.setMinimumIntegerDigits(2);
    formatter.setMinimumFractionDigits(1);
    formatter.setMaximumFractionDigits(1);
    return formatter.format(frameRate);
}

From source file:taximetro.main.java

private void jButtoncomienzoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtoncomienzoActionPerformed
    //Establecer parmetros del nuevo estado de los botones comiezo y fin
    // de carrera, despus de la accin del botn.
    jButtonfin.setEnabled(true);// ww w . java 2  s . c o m
    jButtoncomienzo.setEnabled(false);
    //Borrado del texto existente del area de texto.
    jTextAreaticket.setText("");
    //Guardar la hora de comienzo de carrera al presionar el boton de comenzar.
    Calendar tiempo = Calendar.getInstance(zona);
    DateFormat formatohoras = DateFormat.getTimeInstance(DateFormat.MEDIUM);
    horacomienzocarrera = formatohoras.format(tiempo.getTimeInMillis());
    //Establecer contador de tiempo ponerlo a cero, y inicarlo.
    cronometro.reset();
    cronometro.start();
    //Establecer contador del nmero de ticket.
    ticket++;
    //Darle formato al nmero del ticket con 5 dgitos, sin punto.
    NumberFormat formato = NumberFormat.getInstance();
    formato.setMinimumIntegerDigits(5);
    formato.setGroupingUsed(false);
    textoticket = String.valueOf(formato.format(ticket));

}

From source file:org.mycore.datamodel.ifs.MCRAudioVideoExtender.java

/**
 * Returns the duration of the asset, formatted as a timcode, e. g.
 * "01:15:00" for an asset thats duration is one hour and 15 minutes.
 * /*from  www. j  a  va 2  s  .c o m*/
 * @return the duration foramatted as a timecode like "hh:mm:ss"
 */
public String getDurationTimecode() {
    NumberFormat formatter = NumberFormat.getIntegerInstance(Locale.ROOT);
    formatter.setGroupingUsed(false);
    formatter.setMinimumIntegerDigits(2);
    StringBuilder sb = new StringBuilder();
    sb.append(formatter.format(durationHours));
    sb.append(":");
    sb.append(formatter.format(durationMinutes));
    sb.append(":");
    sb.append(formatter.format(durationSeconds));

    return sb.toString();
}

From source file:com.datasalt.pangool.solr.SolrRecordWriter.java

private String getOutFileName(TaskAttemptContext context, String prefix) {
    TaskID taskId = context.getTaskAttemptID().getTaskID();
    int partition = taskId.getId();
    NumberFormat nf = NumberFormat.getInstance();
    nf.setMinimumIntegerDigits(5);
    nf.setGroupingUsed(false);//from  w  w  w .j  a  va 2 s.c om
    StringBuilder result = new StringBuilder();
    result.append(prefix);
    result.append("-");
    result.append(nf.format(partition));
    return result.toString();
}

From source file:org.hoteia.qalingo.core.domain.CurrencyReferential.java

public NumberFormat getEcoCurrencyformat() {
    NumberFormat formatter = getStandardCurrencyformat();
    formatter.setGroupingUsed(true);//from   w w  w  .  j  a  va2 s  .co  m
    formatter.setParseIntegerOnly(false);
    formatter.setRoundingMode(RoundingMode.HALF_EVEN);

    formatter.setMaximumFractionDigits(2);
    formatter.setMinimumFractionDigits(2);

    formatter.setMaximumIntegerDigits(1000000);
    formatter.setMinimumIntegerDigits(1);
    return formatter;
}

From source file:com.hm.his.module.user.controller.UserController.java

/**
 * <p>Description:<p>/* ww  w.  j av a2s. co m*/
 * @author ZhouPengyu
 * @date 2016-3-2 ?11:39:16
 */
@RequestMapping(value = {
        "/hospitalRegister" }, produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
@ResponseBody
public String register(@RequestBody Map<String, String> requestParams, HttpServletRequest request,
        HttpServletResponse response) {
    String userName = requestParams.get("userName");
    String password = requestParams.get("password");
    String realName = requestParams.get("realName");
    String phone = requestParams.get("phone");
    String mail = requestParams.get("mail");

    String registerInvitation = requestParams.get("registerInvitation");
    String hospitalName = requestParams.get("hospitalName");
    String address = requestParams.get("address");
    String hospitalLicense = requestParams.get("hospitalLicense");
    String invitationCode = requestParams.get("invitationCode");

    String smsCaptcha = requestParams.get("smsCaptcha");

    HisResponse hisResponse = new HisResponse();
    try {
        String sessionId = SessionUtils.getSession().getId();
        String smsCaptchaCache = JedisHelper.get(String.class, sessionId).split("-")[0];
        String cachePhoneNo = JedisHelper.get(String.class, sessionId).split("-")[1];
        log.error(sessionId + "----??" + smsCaptcha + "--??"
                + smsCaptchaCache);
        Map<String, Object> map = new HashMap<String, Object>();
        if ((smsCaptchaCache == null || !smsCaptchaCache.equals(smsCaptcha) || !cachePhoneNo.equals(phone))
                && !"hmluckycharm!".equals(smsCaptcha)) {
            map.put("status", 5);
            hisResponse.setBody(map);
            return hisResponse.toString();
        }

        Doctor doctor = new Doctor();
        if (StringUtils.isNotEmpty(registerInvitation)) {
            if (registerInvitation.equals("huimeitimes")) {
                doctor.setStatus(1l);
            } else {
                hisResponse.setErrorCode(401);
                return hisResponse.toString();
            }
        } else
            doctor.setStatus(1l);

        Hospital hospital = new Hospital();
        hospital.setHospitalName(hospitalName);
        hospital.setAddress(address);
        hospital.setOrganizationLicense(hospitalLicense);
        hospital.setInvitationCode(invitationCode);
        hospitalService.saveHospital(hospital);

        Long number = hospital.getHospitalId();
        NumberFormat formatter = NumberFormat.getNumberInstance();
        formatter.setMinimumIntegerDigits(8);
        formatter.setGroupingUsed(false);
        String s = formatter.format(number);
        hospital.setHospitalNumber(
                "HM" + RC4Utils.encry_RC4_string(s, UUID.randomUUID().toString()).toUpperCase());
        hospitalService.saveHospital(hospital);

        doctor.setDoctorName(userName);
        //?  ---?
        doctor.setPassword(MD5Utils.encrypt(password));
        //??
        doctor.setHighPasswd(MD5Utils.passwordSaltHash(doctor.getDoctorName(), doctor.getPassword()));
        doctor.setRealName(realName);
        doctor.setMail(mail);
        doctor.setPhone(phone);
        doctor.setFlag(1L);
        doctor.setIsAdmin(1l);

        doctor.setHospitalId(hospital.getHospitalId());
        doctorService.saveDoctor(doctor);

        if (doctor.getDoctorId() != null && doctor.getDoctorId() != 0l) {
            //              hospitalExamService.insertDefaultExam(hospital.getHospitalId(), doctor.getDoctorId());
            //              drugService.addDefaultDrugForNewHospital(hospital.getHospitalId(), doctor.getDoctorId());
            map.put("status", doctor.getStatus());
            map.put("doctorId", doctor.getDoctorId());
            if (hospital.getInvitationCode() != null && hospital.getInvitationCode().equals("18684989279"))
                map.put("changeImg", 1);
            else
                map.put("changeImg", 0);
            if (doctor.getStatus() != 1l) {
                smsService.getHospitalSmsConfig(hospital.getHospitalId());
                HmMailUtil.sendMail(doctor, hospital); //??
            }
            hisResponse.setBody(map);
        } else {
            hisResponse.setErrorCode(401);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return hisResponse.toString();
}

From source file:org.mycore.datamodel.ifs2.MCRStore.java

private String createIDWithLeadingZeros(final int ID) {
    final NumberFormat numWithLeadingZerosFormat = NumberFormat.getIntegerInstance(Locale.ROOT);
    numWithLeadingZerosFormat.setMinimumIntegerDigits(idLength);
    numWithLeadingZerosFormat.setGroupingUsed(false);
    final String id = numWithLeadingZerosFormat.format(ID);
    return id;/* w ww  .j  a  va 2  s  .com*/
}

From source file:com.liusoft.dlog4j.velocity.VelocityTool.java

/**
 * (??)//w w w.  ja v  a  2s. c om
 * ?,?
 * @return
 */
public String festival() {
    long[] ds = LunarCalendar.today();
    NumberFormat nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(0);
    nf.setMinimumIntegerDigits(2);
    String nongli = nf.format(ds[1]) + nf.format(ds[2]);
    Calendar cal = Calendar.getInstance();
    String yangli = nf.format(cal.get(Calendar.MONTH) + 1) + nf.format(cal.get(Calendar.DATE));
    //System.out.printf("nongli=%s,yangli=%s\r\n",nongli,yangli);
    String f_nl = getMessage(request, "festival", 'Y' + nongli);
    String f_yl = getMessage(request, "festival", yangli);
    if (f_nl != null && f_yl != null)
        return f_yl + "," + f_nl;
    if (f_nl != null)
        return f_nl;
    if (f_yl != null)
        return f_yl;
    return null;
}

From source file:org.efaps.esjp.common.file.FileUtil_Base.java

/**
 * Method to get a file with given name and ending.
 *
 * @param _name name for the file/*from   w ww  . jav  a  2s.co m*/
 * @return file
 * @throws EFapsException on error
 */
public File getFile(final String _name) throws EFapsException {
    File ret = null;
    try {
        File tmpfld = AppConfigHandler.get().getTempFolder();
        if (tmpfld == null) {
            final File temp = File.createTempFile("eFaps", ".tmp");
            tmpfld = temp.getParentFile();
            temp.delete();
        }
        final File storeFolder = new File(tmpfld, FileUtil_Base.TMPFOLDERNAME);
        final NumberFormat formater = NumberFormat.getInstance();
        formater.setMinimumIntegerDigits(8);
        formater.setGroupingUsed(false);
        final File userFolder = new File(storeFolder,
                formater.format(Context.getThreadContext().getPersonId()));
        if (!userFolder.exists()) {
            userFolder.mkdirs();
        }
        final String name = StringUtils.stripAccents(_name);
        ret = new File(userFolder, name.replaceAll("[^a-zA-Z0-9.-]", "_"));
    } catch (final IOException e) {
        throw new EFapsException(FileUtil_Base.class, "IOException", e);
    }
    return ret;
}

From source file:mx.edu.um.mateo.inventario.dao.impl.FacturaAlmacenDaoHibernate.java

private String getFolio(Almacen almacen) {
    Query query = currentSession()
            .createQuery("select f from Folio f where f.nombre = :nombre and f.almacen.id = :almacenId");
    query.setString("nombre", "FACTURA");
    query.setLong("almacenId", almacen.getId());
    query.setLockOptions(LockOptions.UPGRADE);
    Folio folio = (Folio) query.uniqueResult();
    if (folio == null) {
        folio = new Folio("FACTURA");
        folio.setAlmacen(almacen);/*from   w w  w  .  j ava  2 s .c om*/
        currentSession().save(folio);
        return getFolio(almacen);
    }
    folio.setValor(folio.getValor() + 1);
    java.text.NumberFormat nf = java.text.DecimalFormat.getInstance();
    nf.setGroupingUsed(false);
    nf.setMinimumIntegerDigits(9);
    nf.setMaximumIntegerDigits(9);
    nf.setMaximumFractionDigits(0);
    StringBuilder sb = new StringBuilder();
    sb.append("FA-");
    sb.append(almacen.getEmpresa().getOrganizacion().getCodigo());
    sb.append(almacen.getEmpresa().getCodigo());
    sb.append(almacen.getCodigo());
    sb.append(nf.format(folio.getValor()));
    return sb.toString();
}