Project

General

Profile

Feature #246

Fromatting numbers to blank if zero

Added by Juan Antonio Santana Medina about 13 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
overall
Target version:
-
Start date:
03/11/2011
Due date:
% Done:

0%

Estimated time:
Browser (if web client):

Description

Could be great if we could format numbers to blank if zero. For example $numberFormat("B #,###.00",$number)

I know that replacing zero values to null and using the silent sign could do that, but doing that causes wrong results when doing calculation inside the template.

If I do: #set($Total=$amount1+$amount2+$amount3) and one of the amounts is null nothing is stores into $Total.

I badly need that because I have a report that shows a crosstab with dates and hours with many zeros and the customer is complaining about that.

Thanks.

History

#1

Updated by Patrick Talbot about 13 years ago

  • Tracker changed from Defect to Feature

Problem is that there is no zero formatter for numbers in Java.

One could maybe achieve something like that using a conditional formater, but that's not an easy thing to add (btw, this is a feature request, not a defect).

Alternatively, I could add a special property to $number.format(), but that's also some work which I didn't really plan.

Depending on how badly you/your customer needs it, would you consider sponsoring it?

#2

Updated by Patrick Talbot over 12 years ago

  • Priority changed from High to Normal
#3

Updated by Patrick Talbot almost 12 years ago

  • Category set to overall
  • Priority changed from Normal to Low
  • Client type set to Any
  • In developer? set to No
  • Servoy version set to Any
  • Component version set to v2.0
  • OS version set to Any
  • Java version set to Any
#4

Updated by Patrick Talbot over 11 years ago

  • Status changed from New to In Progress

Added $number.nullIfZero($aNumber).
This will allow you to do something like this:

$!number.format("# ###.00 $", $number.nullIfZero($aNumber))
Which will show as blank if $aNumber is 0

#5

Updated by Patrick Talbot over 11 years ago

  • Status changed from In Progress to Closed

#number.nullIfZero is present with v2.0.27+

Also available in: Atom PDF