Skip to content

Commit

Permalink
Specified culture for string conversion in TLVItem
Browse files Browse the repository at this point in the history
  • Loading branch information
nyxiscoo1 committed Mar 2, 2017
1 parent 79d117c commit b6fe532
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 73 deletions.
7 changes: 4 additions & 3 deletions Source/Core/src/com/shtrih/fiscalprinter/TLVItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.shtrih.util.encoding.IBM866;

import java.util.Date;
import java.util.Locale;

/**
* @author V.Kravtsov
Expand Down Expand Up @@ -40,7 +41,7 @@ public int getLevel() {

public long toInt(byte[] d) {
long result = 0;
for (int i = d.length-1; i >= 0; i--) {
for (int i = d.length - 1; i >= 0; i--) {
result <<= 8;
result |= d[i] & 0xFF;
}
Expand Down Expand Up @@ -126,7 +127,7 @@ public double toFVLN(byte[] data) throws Exception {
public String toFVLNS(byte[] data) throws Exception {
double result = toFVLN(data);
int power = data[0];
return String.format("%." + power + "f", result);
return String.format(Locale.US, "%." + power + "f", result);
}

public String getText() throws Exception {
Expand All @@ -142,7 +143,7 @@ public String getText() throws Exception {
case itUnixTime:
return toDate(data).toString();
case itVLN:
return String.format("%.2f", toInt(data) / 100.0);
return String.format(Locale.US, "%.2f", toInt(data) / 100.0);
case itFVLN:
return toFVLNS(data);
case itASCII:
Expand Down
64 changes: 0 additions & 64 deletions Source/FiscalPrinterService/test/FileAppenderTest.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void Should_decode_int() throws Exception {

TLVItem item = new TLVItem(new TLVInfo(666, TLVInfo.TLVType.itVLN), data, 12);
assertEquals(12345, item.toInt(item.getData()));
assertEquals("123,45", item.getText());
assertEquals("123.45", item.getText());
}

@Test
Expand All @@ -37,7 +37,7 @@ public void Should_decode_vln() throws Exception {

TLVItem item = new TLVItem(new TLVInfo(666, TLVInfo.TLVType.itVLN), data, 12);
assertEquals(132, item.toInt(item.getData()));
assertEquals("1,32", item.getText());
assertEquals("1.32", item.getText());
}

@Test
Expand All @@ -46,7 +46,7 @@ public void Should_decode_vln2() throws Exception {

TLVItem item = new TLVItem(new TLVInfo(666, TLVInfo.TLVType.itVLN), data, 12);
assertEquals(132, item.toInt(item.getData()));
assertEquals("1,32", item.getText());
assertEquals("1.32", item.getText());
}

@Test
Expand All @@ -55,7 +55,7 @@ public void Should_decode_vln3() throws Exception {

TLVItem item = new TLVItem(new TLVInfo(666, TLVInfo.TLVType.itVLN), data, 12);
assertEquals(132, item.toInt(item.getData()));
assertEquals("1,32", item.getText());
assertEquals("1.32", item.getText());
}

private byte[] fsWriteTag(final int data) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void Should_decode_vln_tag() throws Exception {
TLVItem item = items.get(0);

assertEquals(12345, item.toInt(item.getData()));
assertEquals("123,45", item.getText());
assertEquals("123.45", item.getText());
}

private byte[] fsWriteTag(final int tag, final int data) throws Exception {
Expand Down
2 changes: 1 addition & 1 deletion Source/build.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@echo off

cmd /c gradlew clean build uploadArchives
cmd /c gradlew clean build uploadArchives -i
pause

0 comments on commit b6fe532

Please sign in to comment.