java gettime_Java Util.getTime方法代码示例

import org.jrobin.core.Util; //导入方法依赖的package包/类

private void initGraphPeriodAndSize(Range range, int width, int height, RrdGraphDef graphDef) {

// ending timestamp is the (current) timestamp in seconds

// starting timestamp will be adjusted for each graph

final long endTime;

final long startTime;

if (range.getPeriod() == null) {

// si endDate à la date du jour, alors on ne dépasse pas l'heure courante

endTime = Math.min(range.getEndDate().getTime() / 1000, Util.getTime());

startTime = range.getStartDate().getTime() / 1000;

} else {

endTime = Util.getTime();

startTime = endTime - range.getPeriod().getDurationSeconds();

}

final String label = getLabel();

final String titleStart;

if (label.length() > 31 && width <= 200) {

// si le label est trop long, on raccourci le titre sinon il ne rentre pas

titleStart = label;

} else {

titleStart = label + " - " + range.getLabel();

}

final String titleEnd;

if (width > 400) {

if (range.getPeriod() == null) {

titleEnd = " - " + I18N.getFormattedString("sur", getApplication());

} else {

titleEnd = " - " + I18N.getCurrentDate() + ' '

+ I18N.getFormattedString("sur", getApplication());

}

} else {

titleEnd = "";

if (range.getPeriod() == null) {

// si période entre 2 dates et si pas de zoom,

// alors on réduit de 2 point la fonte du titre pour qu'il rentre dans le cadre

graphDef.setLargeFont(graphDef.getLargeFont()

.deriveFont(graphDef.getLargeFont().getSize2D() - 2f));

}

}

graphDef.setStartTime(startTime);

graphDef.setEndTime(endTime);

graphDef.setTitle(titleStart + titleEnd);

graphDef.setFirstDayOfWeek(

Calendar.getInstance(I18N.getCurrentLocale()).getFirstDayOfWeek());

// or if the user locale patch is merged we should do:

// (https://sourceforge.net/tracker/?func=detail&aid=3403733&group_id=82668&atid=566807)

//graphDef.setLocale(I18N.getCurrentLocale());

// rq : la largeur et la hauteur de l'image sont plus grandes que celles fournies

// car jrobin ajoute la largeur et la hauteur des textes et autres

graphDef.setWidth(width);

graphDef.setHeight(height);

if (width <= 100) {

graphDef.setNoLegend(true);

graphDef.setUnitsLength(0);

graphDef.setShowSignature(false);

graphDef.setTitle(null);

}

//graphDef.setColor(RrdGraphConstants.COLOR_BACK, new GradientPaint(0, 0,

//RrdGraphConstants.DEFAULT_BACK_COLOR.brighter(), 0, height,

//RrdGraphConstants.DEFAULT_BACK_COLOR));

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值