use the android time object instead of the java calendar class

This commit is contained in:
benfry
2010-02-27 17:14:44 +00:00
parent 55107db932
commit 5b12d99d90
+21 -6
View File
@@ -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.
* <P>
@@ -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;</PRE>
*/
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;
}