Revision 45897 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.dbf/src/main/java/org/gvsig/fmap/dal/store/dbf/utils/FieldFormatter.java
FieldFormatter.java | ||
---|---|---|
34 | 34 |
import java.util.Date; |
35 | 35 |
import java.util.Locale; |
36 | 36 |
import org.apache.commons.lang3.StringUtils; |
37 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
38 | 37 |
import org.gvsig.tools.logger.FilteredLogger; |
39 | 38 |
import org.slf4j.Logger; |
40 | 39 |
import org.slf4j.LoggerFactory; |
... | ... | |
201 | 200 |
if(index < 0 || index >= size ) { |
202 | 201 |
throw new BufferOverflowException(); |
203 | 202 |
} |
204 |
s = s.substring(0, size); |
|
203 |
if(index == size-1 ) { |
|
204 |
s = s.substring(0, size-1); |
|
205 |
} else { |
|
206 |
s = s.substring(0, size); |
|
207 |
} |
|
205 | 208 |
} |
206 | 209 |
return s; |
207 | 210 |
} |
208 | 211 |
|
209 | 212 |
public String format(double n, int size, int scale) { |
210 |
String s = Double.toString(n);
|
|
213 |
String s = String.format(Locale.ENGLISH, "%f", n);
|
|
211 | 214 |
if (s.length() > size) { |
212 |
if(s.indexOf('E') >= 0){ |
|
213 |
//FIXME: |
|
214 |
throw new BufferOverflowException(); |
|
215 |
} |
|
216 | 215 |
int index = s.indexOf('.'); |
217 | 216 |
if(index < 0 || index >= size ) { |
218 | 217 |
throw new BufferOverflowException(); |
219 | 218 |
} |
220 |
s = s.substring(0, size); |
|
221 |
|
|
219 |
if(index == size-1 ) { |
|
220 |
s = s.substring(0, size-1); |
|
221 |
} else { |
|
222 |
s = s.substring(0, size); |
|
223 |
} |
|
222 | 224 |
} |
223 | 225 |
return s; |
224 | 226 |
} |
225 | 227 |
|
226 | 228 |
public String format(float n, int size, int scale) { |
227 |
String s = Float.toString(n);
|
|
229 |
String s = String.format(Locale.ENGLISH, "%f", n);
|
|
228 | 230 |
if (s.length() > size) { |
229 |
if(s.indexOf('E') >= 0){ |
|
230 |
//FIXME: |
|
231 |
throw new BufferOverflowException(); |
|
232 |
} |
|
233 | 231 |
int index = s.indexOf('.'); |
234 | 232 |
if(index < 0 || index >= size ) { |
235 | 233 |
throw new BufferOverflowException(); |
236 | 234 |
} |
237 |
|
|
238 |
s = s.substring(0, size); |
|
235 |
if(index == size-1 ) { |
|
236 |
s = s.substring(0, size-1); |
|
237 |
} else { |
|
238 |
s = s.substring(0, size); |
|
239 |
} |
|
239 | 240 |
} |
240 | 241 |
return s; |
241 | 242 |
} |
Also available in: Unified diff