mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
use the android time object instead of the java calendar class
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user