Skip to content

Instantly share code, notes, and snippets.

@yishai-glide
Created May 22, 2017 13:05
Show Gist options
  • Save yishai-glide/98b1e603fac87ece2b1dc024fca13a7e to your computer and use it in GitHub Desktop.
Save yishai-glide/98b1e603fac87ece2b1dc024fca13a7e to your computer and use it in GitHub Desktop.
public class Alerts {
class Alert {
byte cell_id;
byte type;
Calendar start_datetime = new GregorianCalendar();
byte duration;
byte data1;
}
public static Alerts.Alert[] g_alerts=new Alerts.Alert[49];
public void TestCalender()
{
Alerts.Alert alert_temp= alerts.new Alert();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
for (i=0;i<49;i++)
{
g_alerts[i]= alerts.new Alert();
g_alerts[i].start_datetime.clear();
}
g_alerts_count=0;
while (index<length+4)//save raw data from server
{
alert_temp.start_datetime.set(2000+ mBuffer[mBufferIndex +index+2],mBuffer[mBufferIndex +index+3]-1,mBuffer[mBufferIndex +index+4],mBuffer[mBufferIndex +index+6],mBuffer[mBufferIndex +index+7],0);
g_alerts[g_alerts_count].start_datetime = alert_temp.start_datetime;
strDate = sdf.format(g_alerts[g_alerts_count].start_datetime.getTime());
Log.d(TAG, "alert set to time:"+ strDate );
//log from logcat to first row in the g_alerts array
//alert set to time: 28-05-2017 15:30:00
g_alerts_count++;
}
}
@Override
public void run() {
try {
TestCalender();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
for (int i=0;i<g_alerts_count;i++) {
String strDate = sdf.format(g_alerts[i].start_datetime.getTime());
Log.d(TAG, "alert set to time:"+ strDate );
}
//log from logcat to first row in the g_alerts array
//alert set to time: 27-05-2017 15:30:00
}
catch
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment