Examples of UnitNumber


Examples of org.rhq.core.clientapi.util.units.UnitNumber

    public static final long MILLIS_IN_HOUR = MILLIS_IN_MINUTE * 60;
    public static final long MILLIS_IN_DAY = MILLIS_IN_HOUR * 24;
    public static final long MILLIS_IN_WEEK = MILLIS_IN_DAY * 7;

    public static String toString(long time) {
        UnitNumber number = new UnitNumber(time, UnitsConstants.UNIT_DATE, ScaleConstants.SCALE_MILLI);

        return UnitsFormat.format(number).toString();
    }
View Full Code Here

Examples of org.rhq.core.clientapi.util.units.UnitNumber

        // by the logic above, if sum is zero then count is also zero
        // so, shortcut the result as 0 if this is the case, otherwise result sum / count
        double result = ((sum == 0) ? 0 : (sum / count));

        UnitNumber average = new UnitNumber(result, UnitsConstants.UNIT_PERCENTAGE);
        return UnitsFormat.format(average).toString();
    }
View Full Code Here

Examples of org.rhq.core.clientapi.util.units.UnitNumber

        UnitsConstants unit = UnitsConstants.UNIT_DATE;
        String key = StringConstants.UNIT_FORMAT_PREFIX_KEY + "epoch-millis";
        String formatString = RequestUtils.message(FacesContextUtility.getRequest(), key);
        DateFormatter.DateSpecifics specs = new DateFormatter.DateSpecifics();
        specs.setDateFormat(new SimpleDateFormat(formatString));
        FormattedNumber fmtd = UnitsFormat.format(new UnitNumber(timestamp, unit, ScaleConstants.SCALE_MILLI),
            FacesContextUtility.getRequest().getLocale(), specs);
        return fmtd.toString();
    }
View Full Code Here

Examples of org.rhq.core.clientapi.util.units.UnitNumber

        long fileSizeBytes = (current.getPackageVersion().getFileSize() != null) ? current.getPackageVersion()
            .getFileSize() : 0;
        long oldFileSizeBytes = (old != null) ? ((old.getPackageVersion().getFileSize() != null) ? old
            .getPackageVersion().getFileSize() : 0) : 0;
        results.add(new PackageTableDataValue("File Size", UnitsFormat.format(
            new UnitNumber(fileSizeBytes, UnitsConstants.UNIT_BYTES)).toString(), UnitsFormat.format(
            new UnitNumber(oldFileSizeBytes, UnitsConstants.UNIT_BYTES)).toString()));

        results.add(new PackageTableDataValue("SHA256", current.getPackageVersion().getSHA256(), ((old != null) ? old
            .getPackageVersion().getSHA256() : null)));
        results.add(new PackageTableDataValue("Installation Date", dateToString(current.getInstallationDate()),
            dateToString((old != null) ? old.getInstallationDate() : null)));
View Full Code Here

Examples of org.rhq.core.clientapi.util.units.UnitNumber

        // by the logic above, if sum is zero then count is also zero
        // so, shortcut the result as 0 if this is the case, otherwise result sum / count
        double result = ((sum == 0) ? 0 : (sum / count));

        UnitNumber average = new UnitNumber(result, UnitsConstants.UNIT_PERCENTAGE);
        return UnitsFormat.format(average).toString();
    }
View Full Code Here

Examples of org.rhq.core.clientapi.util.units.UnitNumber

        DateFormatter.DateSpecifics dateSpecs;

        dateSpecs = new DateFormatter.DateSpecifics();
        dateSpecs.setDateFormat(new SimpleDateFormat(formatString));
        FormattedNumber fmtd = UnitsFormat.format(new UnitNumber(newDate.doubleValue(), unit,
            ScaleConstants.SCALE_MILLI), getPageContext().getRequest().getLocale(), dateSpecs);
        buf.append(fmtd.toString());
        return buf.toString();
    }
View Full Code Here

Examples of org.rhq.core.clientapi.util.units.UnitNumber

            } else if (unit.equals("ms")) {
                // we don't care about scaling and such. we just want
                // to show every metric in seconds with millisecond
                // resolution
                String formatted = UnitsFormat.format(
                    new UnitNumber(m.doubleValue(), UnitsConstants.UNIT_DURATION, ScaleConstants.SCALE_MILLI))
                    .toString();
                buf.append(formatted);
            } else {
                MeasurementUnits targetUnits = MeasurementUnits.valueOf(unit);
                Double dataValue = m.doubleValue();
View Full Code Here

Examples of org.rhq.core.clientapi.util.units.UnitNumber

        }

        String formatString = RequestUtils.message((HttpServletRequest) pageContext.getRequest(), key);
        DateSpecifics specs = new DateSpecifics();
        specs.setDateFormat(new SimpleDateFormat(formatString));
        FormattedNumber fmtd = UnitsFormat.format(new UnitNumber(date.doubleValue(), unit, ScaleConstants.SCALE_MILLI),
            pageContext.getRequest().getLocale(), specs);
        return fmtd.toString();
    }
View Full Code Here

Examples of org.rhq.core.clientapi.util.units.UnitNumber

                    DateSpecifics specs = new DateSpecifics();
                    specs.setDateFormat(new SimpleDateFormat(res.getMessage(Constants.UNIT_FORMAT_PREFIX_KEY
                        + "epoch-millis")));

                    FormattedNumber fmtd = UnitsFormat.format(new UnitNumber(alert.getCtime(),
                        UnitsConstants.UNIT_DATE, ScaleConstants.SCALE_MILLI), request.getLocale(), specs);

                    feed.addItem(alert.getAlertDefinition().getResource().getName() + " "
                        + alert.getAlertDefinition().getName(), link, fmtd.toString(), alert.getCtime());
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.