# A simple 0-filling program

**URL:** https://discourse.processing.org/t/a-simple-0-filling-program/25983
**Category:** Gallery
**Created:** [December 5, 2020, 9:13pm UTC](https://discourse.processing.org/t/a-simple-0-filling-program/25983 "2020-12-05T21:13:05Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)
#### Post date: [December 5, 2020, 9:13pm UTC](https://discourse.processing.org/t/a-simple-0-filling-program/25983/1 "2020-12-05T21:13:05Z")

</div>

Hi!  
Isn’t it annoying that the “hour()”, “minute()”, “second()”, … functions output unorganised integers?  
(For example, if the time is 21:05:09, than the second() function would return “9” instead of “09”)

Here is a simple program to fix it!

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/5/50c918163fd0c9998360c905731f3adef32e040f.png)

Here is the code:

```auto
void setup() {
}

void draw() {
  println("The better way: " + loadZeros(hour(),2) + ":" + loadZeros(minute(),2) + ":" + loadZeros(second(),2));
  println("The normal way: " + hour()+":"+minute()+":"+second());
  println("");
}

String loadZeros(int number, int len) {
  if((number+"").length() < len) {
    String prefix = "";
    for(int i = 0; i < len-(number+"").length(); i++) {
      prefix += "0";
    }
    return(prefix + number);
  } else {
    return(number+"");
  }
}

```

With this you can also turn any intiger into intigers with length. (input loadZeros(131,5), output=“00131” (in String form).

Feel free to use it in any of your projects!

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [December 5, 2020, 9:14pm UTC](https://discourse.processing.org/t/a-simple-0-filling-program/25983/2 "2020-12-05T21:14:49Z")

</div>

> **[nf() \\ Language (API) \\ Processing 3+](https://Processing.org/reference/nf_.html)**

---

<div class="post-metadata">

### Author: ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)
#### Post date: [December 5, 2020, 9:17pm UTC](https://discourse.processing.org/t/a-simple-0-filling-program/25983/3 "2020-12-05T21:17:27Z")

</div>

Well… honestly I didn’t know. Looks like it already exists

---

<div class="post-metadata">

### Author: ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)
#### Post date: [December 5, 2020, 9:18pm UTC](https://discourse.processing.org/t/a-simple-0-filling-program/25983/4 "2020-12-05T21:18:37Z")

</div>

Is there a way to see the sourcecode of an already existing function?

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [December 5, 2020, 9:21pm UTC](https://discourse.processing.org/t/a-simple-0-filling-program/25983/5 "2020-12-05T21:21:30Z")

</div>

> <https://github.com/processing/processing/blob/processing-0270-3.5.4/core/src/processing/core/PApplet.java#L9946-L9959>

---

<div class="post-metadata">

### Author: ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)
#### Post date: [December 5, 2020, 9:28pm UTC](https://discourse.processing.org/t/a-simple-0-filling-program/25983/6 "2020-12-05T21:28:00Z")

</div>

So this is all the code that runs processing functions? But then why do the processing export files take up 70mb even for a simple clock? (I don’t know much about programming languages)

Edit: Don’t normal Java apps take 1/10 of that?

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [December 5, 2020, 9:31pm UTC](https://discourse.processing.org/t/a-simple-0-filling-program/25983/7 "2020-12-05T21:31:34Z")

</div>

> [@CodeMasterX](#):
>
> But then why do the Processing export files take up 70mb even for a simple clock?

[Generated Documentation (Untitled)](http://Processing.GitHub.io/processing-javadocs/core/)
