crvnav/app/src/test/java/com/flywithu/carnav/ExampleUnitTest.java
2019-11-18 05:39:08 +09:00

74 lines
2.0 KiB
Java

package com.flywithu.carnav;
import org.junit.Test;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
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);
}
private static String bytesToHex(byte[] hashInBytes) {
StringBuilder sb = new StringBuilder();
for (byte b : hashInBytes) {
sb.append(String.format("%02x", b));
}
return sb.toString();
}
@Test
public void myTest()
{
RealService rs = new RealService();
rs.getStringToByte("U4PL23|헤어지자 (Prod. 정키)|", Charset.forName("UTF-8"));
}
@Test
public void checkout()
{
//55 34 50 4C 33 33 7C ED 9C 98 EC 9D B8 20 28 57 68 65 65 20 49 6E 29 7C 0D
String test = "A지어반Z";
//EC A7 80 EC 96 B4 EB B0 98
System.out.println(test);
try {
System.out.println(bytesToHex(test.getBytes("utf-8")));
System.out.println(bytesToHex(test.getBytes("utf-16")));
System.out.println(bytesToHex(test.getBytes("utf-32")));
}
catch(Exception e)
{
e.printStackTrace();
}
}
}