diff --git a/android/core/src/processing/core/PApplet.java b/android/core/src/processing/core/PApplet.java index e7ef46776..813189f88 100644 --- a/android/core/src/processing/core/PApplet.java +++ b/android/core/src/processing/core/PApplet.java @@ -39,6 +39,7 @@ import java.util.zip.*; import android.app.Activity; import android.opengl.GLSurfaceView; +import android.text.format.Time; import android.util.DisplayMetrics; import android.util.Log; import android.view.SurfaceView; @@ -1729,6 +1730,8 @@ public class PApplet extends Activity implements PConstants, Runnable { // getting the time + static protected Time time = new Time(); + /** * Get the number of milliseconds since the applet started. *

@@ -1741,12 +1744,16 @@ public class PApplet extends Activity implements PConstants, Runnable { /** Seconds position of the current time. */ static public int second() { - return Calendar.getInstance().get(Calendar.SECOND); + //return Calendar.getInstance().get(Calendar.SECOND); + time.setToNow(); + return time.second; } /** Minutes position of the current time. */ static public int minute() { - return Calendar.getInstance().get(Calendar.MINUTE); + //return Calendar.getInstance().get(Calendar.MINUTE); + time.setToNow(); + return time.minute; } /** @@ -1757,7 +1764,9 @@ public class PApplet extends Activity implements PConstants, Runnable { * if (yankeeHour == 0) yankeeHour = 12; */ static public int hour() { - return Calendar.getInstance().get(Calendar.HOUR_OF_DAY); + //return Calendar.getInstance().get(Calendar.HOUR_OF_DAY); + time.setToNow(); + return time.hour; } /** @@ -1767,7 +1776,9 @@ public class PApplet extends Activity implements PConstants, Runnable { * or day of the year (1..365) then use java's Calendar.get() */ static public int day() { - return Calendar.getInstance().get(Calendar.DAY_OF_MONTH); + //return Calendar.getInstance().get(Calendar.DAY_OF_MONTH); + time.setToNow(); + return time.monthDay; } /** @@ -1775,14 +1786,18 @@ public class PApplet extends Activity implements PConstants, Runnable { */ static public int month() { // months are number 0..11 so change to colloquial 1..12 - return Calendar.getInstance().get(Calendar.MONTH) + 1; + //return Calendar.getInstance().get(Calendar.MONTH) + 1; + time.setToNow(); + return time.month + 1; } /** * Get the current year. */ static public int year() { - return Calendar.getInstance().get(Calendar.YEAR); + //return Calendar.getInstance().get(Calendar.YEAR); + time.setToNow(); + return time.year; }