FirstCommit
This commit is contained in:
parent
fd9c7bf382
commit
91b1ff2a93
@ -44,6 +44,22 @@ public class RealService extends Service {
|
|||||||
public RealService() {
|
public RealService() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sendSerial(String str)
|
||||||
|
{
|
||||||
|
if(sPort!=null)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
sPort.write(str.getBytes(), 3000);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
serviceIntent = intent;
|
serviceIntent = intent;
|
||||||
@ -98,7 +114,16 @@ public class RealService extends Service {
|
|||||||
sPort = null;
|
sPort = null;
|
||||||
}
|
}
|
||||||
//set the time
|
//set the time
|
||||||
|
//TMST001801140907
|
||||||
|
//TMST00YYDDDD0907
|
||||||
|
|
||||||
|
SimpleDateFormat format1 = new SimpleDateFormat ( "00yyMMddHHmm");
|
||||||
|
// String f = format1.format(System.currentTimeMillis());
|
||||||
|
String currentInfo = format1.format(new Date());
|
||||||
|
String currentTime = String.format("TMST%s",currentInfo);
|
||||||
|
sendSerial(currentTime);
|
||||||
|
|
||||||
|
showToast(getApplication(),currentTime);
|
||||||
|
|
||||||
// try {
|
// try {
|
||||||
// sPort.write("zxcv".getBytes(), 50);
|
// sPort.write("zxcv".getBytes(), 50);
|
||||||
|
@ -2,6 +2,10 @@ package com.flywithu.carnav;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,4 +18,22 @@ public class ExampleUnitTest {
|
|||||||
public void addition_isCorrect() {
|
public void addition_isCorrect() {
|
||||||
assertEquals(4, 2 + 2);
|
assertEquals(4, 2 + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void checkDate()
|
||||||
|
{
|
||||||
|
LocalDateTime currentDateTime = LocalDateTime.now();
|
||||||
|
//TMST001801140907
|
||||||
|
//TMST00YYDDDD0907
|
||||||
|
|
||||||
|
Date myDate = new Date ( "Sun,5 Dec 1999 00:07:21" );
|
||||||
|
|
||||||
|
|
||||||
|
SimpleDateFormat format1 = new SimpleDateFormat ( "yy MM dd HH mm");
|
||||||
|
// String f = format1.format(System.currentTimeMillis());
|
||||||
|
String f = format1.format(myDate);
|
||||||
|
System.out.println(f);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user