Архив

Posts Tagged ‘конвертирование’

OAF: Конвертация типов

Тип Конвертирование
STRING to NUMBER
byte Byte.parseByte(«123»)
byte Byte.valueOf(«123»).byteValue()
short Short.parseShort(«123»)
short Short.valueOf(«123»).shortValue()
int Integer.parseInt(«123»)
int Integer.valueOf(“123”).intValue()
long Long.parseLong(«123»)
long Long.valueOf(«123»).longValue()
float Float.parseFloat(«123.4»)
float Float.valueOf(«123.4»).floatValue()
double Double.parseDouble(«123.4e10»)
double Double.valueOf(«123.4e10»).doubleValue()
Number new Number(Integer.parseInt(«123»))
NUMBER to STRING
String “” + 123
String Number pageContext.getOANLSServcies().NumberToString(num,»###,###,##0.00000;-###,###,##0.00000″);
String int Integer.toString(123)
String double Double.toString(123.4e10)
String long Long.toString(123)
String float Float.toString(123.4)
STRING to DATE
Date String DATE_FORMAT = «dd-mm-yyyy»;

java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT);

Date myDate =  sdf.parse(“01-10-2010”)

Date java.sql.Date myDate = pageContext.getOANLSServcies().stringToDate(“01-10-2010”);

oracle.jbo.domain.Date date1 = new Date(myDate);

Конвертирование единиц измерения

Пакет inv_convert

FUNCTION inv_um_convert(p_item_id       IN NUMBER,
                        p_from_uom_code IN VARCHAR2,
                        p_to_uom_code   IN VARCHAR2) RETURN NUMBER;

Пример:

select msi.segment1,
       msi.primary_uom_code,
       'кг' as second_uom,
       inv_convert.inv_um_convert(msi.inventory_item_id,'кг',
                                  msi.primary_uom_code) as coefficient
from mtl_system_items_b msi
where msi.primary_uom_code = 'т'
and rownum <= 10