Groovy web console

subscribe to the feed Subscribe
to this
site
doubleFormatter (via #groovywebconsole)
tweet this snippet Tweet
this
script

doubleFormatter

Published 9 months ago by You
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
    public static String doubleFormatter(var doubleMegabytes){
    if ( doubleMegabytes != null ) {
            Double doubleBytes = doubleMegabytes * 1024 * 1024;
            String stringBytes = String.format("%.0f", doubleBytes);
            return stringBytes;
    } 
    else {
            
            return null;
         }
    }
    
   println(doubleFormatter());