How to convert data read in byte to decimal number?
The following are a source code to read from a serial port, but i can't convert the data that i read to decimal number and write it on a text file.....can anyone kindly show me how to solve it? thanks
import javax.comm.*;
import java.io.*;
import java.util.*;
public class Read implements Runnable, SerialPortEventListener {
// Attributes for Serial Communication
static Enumeration portList;
static CommPortIdentifier portId;
SerialPort serialPort;
static OutputStream outputStream;
InputStream inputStream;
Thread readThread;
public static void main(String s[])
portList=CommPortIdentifier.getPortIdentifiers();
while(portList.hasMoreElements())
portId=(CommPortIdentifier)portList.nextElement();
if(portId.getPortType()==CommPortIdentifier.PORT_SERIAL)
if(portId.getName().equals("COM1"))
System.out.println( portId.getName());
Read ss=new Read();
} // end of while
} // end of main
public Read() {
try{
serialPort=(SerialPort)portId.open("Read", 2000);
catch(PortInUseException e) {}
try{
inputStream=serialPort.getInputStream();
System.out.println(inputStream);
catch(IOException e) {}
try{
serialPort.addEventListener(this);
catch(Exception e) {}
serialPort.notifyOnDataAvailable(true);
try{
serialPort.setSerialPortParams(9600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
}catch(UnsupportedCommOperationException e) {}
readThread=new Thread(this);
readThread.start();
}//end of constructor
public void run()
try {
Thread.sleep(200);
}catch(InterruptedException e) {}
public void serialEvent(SerialPortEvent event)
switch(event.getEventType())
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
byte[]readBuffer=new byte[8];
try{
while(inputStream.available()>0)
int numBytes=inputStream.read(readBuffer);
//System.out.println("hello");
System.out.print(new String(readBuffer));
}catch(IOException e) {}
break;
} // end of switch
try {
inputStream.close();
}catch(Exception e5) {}
} // end of serialEvent
Is it a float or a double?
For a float, the decimal should be 4 bytes (small numbers like 1.1 start with the byte 0x40). Convert these 4 bytes to an int, using byte-shifting would probably be easiest.
int value = ((b3 << 24) + (b2 << 16) + (b1 << 8) + b0);//b# are bytesNow to convert it to a float, use
Float.intBitsToFloat(value);Now if you want double percision, You will have 8 bytes instead of 4, and need to be converted to a long instead of an int through byte-shifting. Then use Double.longBitsToDouble(long bits) to get the double
Similar Messages
-
How to convert an Integer to byte[] without lose data?
How to convert an Integer to byte[] without lose data?
I use the following to convert any java Object to a byte array
public static byte[] getBytes(Object obj) throws java.io.IOException
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(obj);
oos.flush();
oos.close();
bos.close();
byte [] data = bos.toByteArray();
return data;
} -
How to Convert Date (DD.MM.YYYY) to be just DD
Hi experts,
I have no idea how to convert Date format (DDMMYYYY) to be just DD.
Example:
I have date: 31.10.2009
now i just want to show in report as 31.
I just known if we just want to show month only, we could use the 0CALMONTH2. but how if i need the day only?
Are there any way, either in query (BEx) or modeling (Routine/Formula in Update Rules or Transfer Rules) which could fulfill the requirement?
Many thanks..
Warm Regards,
TikaHi,
go through the link below and modify according to your requirement
Date conversion from YYYYMMDD to DD.MM.YYYY
Regards,
Marasa. -
How to Convert Date to Month in Database which is pointing to EBS, Not DWH.
Hi Friends,
We are planning to create reports in OBIEE and the Source is EBS. That means, we don’t want to depends on Datawarehouse and Informatica and OBIApps. We just create some reports and they are pointing to EBS database.
For testing purpose, we have taken one HR Report and it containsthe below columns:
Month (Dim)
Revenue Per Employee Headcount (Fact)
Average Cost per Active Workforce Headcount (Fact)
In my little investigation, we found that Revenue column is coming from EBS: GL_BALANCES. And we configured W_Day_D base table in DAC as there is no Month column in EBS (Not sure).
*** Coming to my problem, how can I call Month column in my database pointed to EBS. How to convert Date to Month in my database.
I could be wrong but anyone please look into this issue.. How can I create columns for that exact OBI report in EBS database instead of DwH.
Thanks in Advance..
Raghu NagadasariHi Veeresh,
You are right. Here, no need of using W_DAY_D table, but, we need all the stuff from the table and to explain my problem i have taken that table as an example. Now, we ran scripts for W_MONTH_D and W_DAY_D tables with EBS columns. So, we are getting data for the tables. In the same manner we have to create scripts for the below tables.
W_GL_ACCOUNT_D
W_GL_OTHER_F
W_STATUS_D
W_MCAL_DAY_D
W_EMPLOYMENT_STAT_CAT_D
W_WRKFC_BAL_A
W_DAY_D (Completed)
W_MONTH_D (Completed)
But, we are not aware of EBS Tables and their columns much. So, we are back tracing from RpD --> DAC --> Info --> EBS for each and every column and its taking much time.
So, if anyone of you facing the same issue, please share the EBS tables for the corresponding OBI tables, which are mentioned above. -
How to convert DATE variable to CHAR variable
dear all,
How to convert DATE variable to CHAR variable
thanqDepending on your final goal here are 2 options.
DATA: datein TYPE d.
DATA: dateout(10) TYPE c.
DATA: dateout2(8) TYPE c.
datein = sy-datum.
WRITE datein TO dateout MM/DD/YYYY.
dateout2 = datein.
WRITE:/ datein, dateout, dateout2.
and the output
05022008 05/02/2008 20080502 -
How to convert date dd.mm.yyyy TO Month ddth YYYY?
hi friends,
how to convert date into this format.
ex:
date : 04.11.2008
has to convert as
October 04th, 2008
th has to be set SUPERSCRIPT.
Plz any helps....
Regards,
Shankar.check this..FM
CONVERT_DATE_TO_EXTERNAL
or we can do this using split or concatenate functions like below
*CALCULATING THE MONTH FOR THE BODY OF THE EMAIL MSG
IF GD_EBODY_BB = '01' .
GD_EBODY_BB = 'January' .
ELSEIF GD_EBODY_BB = '02' .
GD_EBODY_BB = 'February' .
ELSEIF GD_EBODY_BB = '03' .
GD_EBODY_BB = 'March' .
ELSEIF GD_EBODY_BB = '04' .
GD_EBODY_BB = 'April' .
ELSEIF GD_EBODY_BB = '05' .
GD_EBODY_BB = 'May' .
ELSEIF GD_EBODY_BB = '06' .
GD_EBODY_BB = 'June' .
ELSEIF GD_EBODY_BB = '07' .
GD_EBODY_BB = 'July' .
ELSEIF GD_EBODY_BB = '08' .
GD_EBODY_BB = 'August' .
ELSEIF GD_EBODY_BB = '09' .
GD_EBODY_BB = 'September' .
ELSEIF GD_EBODY_BB = '10' .
GD_EBODY_BB = 'October' .
ELSEIF GD_EBODY_BB = '11' .
GD_EBODY_BB = 'November' .
ELSEIF GD_EBODY_BB = '12' .
GD_EBODY_BB = 'December' .
ENDIF .
*ATTACHMENT SUBJECT LINE MODIFICATION
IF GD_EBODY_CC = '01'.
CONCATENATE GD_EBODY_CC 'st' INTO GD_EBODY_CC .
ELSEIF GD_EBODY_CC = '02' .
CONCATENATE GD_EBODY_CC 'nd' INTO GD_EBODY_CC .
ELSEIF GD_EBODY_CC = '03' .
CONCATENATE GD_EBODY_CC 'rd' INTO GD_EBODY_CC .
ELSEIF GD_EBODY_CC = '31'.
CONCATENATE GD_EBODY_CC 'st' INTO GD_EBODY_CC .
ELSEIF GD_EBODY_CC = '21'.
CONCATENATE GD_EBODY_CC 'st' INTO GD_EBODY_CC .
ELSE .
CONCATENATE GD_EBODY_CC 'th' INTO GD_EBODY_CC .
ENDIF .
regards
ansumesh
Edited by: Ansumesh Kumar Samal on Nov 4, 2008 9:02 AM -
How to convert date format dd.mm.yy into yyyymmdd?
Hello experts,
how to convert date format dd.mm.yy into yyyymmdd?
Thanx
AxelHi
go through these previous threads on similar question
https://forums.sdn.sap.com/click.jspa?searchID=673529&messageID=1763194
Date Conversion in Flat File
converting the DATE(yyyymmdd) into MONTH(yyyymm) format
Date Format Conversion from MM.DD.YYYY to YYYYMMDD
gives clear idea
Reagrds
Kiran
Message was edited by:
ravi kiran naalla -
How to convert Date format into day in ssrs reports?
Hi
How to convert date format into day?
10/01/2010 as like Monday like that?=weekdayname(datepart("w",Fields!mydate.Value))
-Vaibhav Chaudhari -
How to convert date (dd/mm/yyyy) to week no. calendar?
hi all,
I have a question about if user enters 12/12/2004(dd/mm/yyyy), which week is that? I just know week no. should from 01 to no more than 53. How to convert date to week no.?
Thanksselect to_char(sysdate,'IW'),to_char(sysdate,'wW') from dual;
for IW, the week 2 starts on the first monday after 1.Jan, for WW, the week 2 starts on 8. Jan.
HTH
Laurent Schneider
OCM DBA -
How to convert date format to MM/DD/YYYY
Hi,
How to convert date format to MM/DD/YYYY.
Thanks,
Senthilhi,
tri with this function module
data :l_date(10) type c
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
EXPORTING
DATE_INTERNAL = SY-DATUM
IMPORTING
DATE_EXTERNAL = l_date.
this function module converts date from 20050601 to external format which is specified in user profile
cheers,
sasi -
How to convert date from ccyymm format to mmddyy
hi,
How to convert date from ccyymm format to mmddyyPlease don't multipost. This question has been answered in your first post.
How to convert date to ccyymm format
Regards,
Jo -
How to convert date to ccyymm format
Hi,
How to convert date to ccyymm format.
Thanksdadivela wrote:
Re: How to convert date from ccyymm format to mmddyyI didn't inderstand. Date doesn't have any format. If you have a string in CCYYMM format, you would have to extract the YYMM from the string.
SQL> SELECT SYSDATE,
2 TO_CHAR (SYSDATE, 'ccyymm') Date_Fm,
3 SUBSTR (TO_CHAR (SYSDATE, 'ccyymm'), 3) YYMM
4 FROM DUAL
5 /
SYSDATE DATE_F YYMM
08-JUN-09 210906 0906You can use this string to convert it to date. Note that since DD part of your date was not their in the resultan string, the converted date will fall back to first of the month specified.
SQL> SELECT SYSDATE,
2 TO_CHAR (SYSDATE, 'ccyymm') Date_Fm,
3 SUBSTR (TO_CHAR (SYSDATE, 'ccyymm'), 3) YYMM,
4 TO_DATE (SUBSTR (TO_CHAR (SYSDATE, 'ccyymm'), 3), 'YYMM') conv_Dat
e
5 FROM DUAL
6 /
SYSDATE DATE_F YYMM CONV_DATE
08-JUN-09 210906 0906 01-JUN-09
SQL>Then convert the date into the required format using TO_CHAR Function
SQL> SELECT SYSDATE,
2 TO_CHAR (SYSDATE, 'ccyymm') Date_Fm,
3 SUBSTR (TO_CHAR (SYSDATE, 'ccyymm'), 3) YYMM,
4 TO_DATE (SUBSTR (TO_CHAR (SYSDATE, 'ccyymm'), 3),
5 'YYMM') conv_Date,
6 TO_CHAR(TO_DATE(SUBSTR(TO_CHAR (SYSDATE, 'ccyymm'),3),
7 'YYMM'), 'MMDDYY') New_Format
8 FROM DUAL
9 /
SYSDATE DATE_F YYMM CONV_DATE NEW_FO
08-JUN-09 210906 0906 01-JUN-09 060109
SQL>Hope this helps.
Regarads,
Jo -
How to convert date to milliseconds?
hi,
can anybody tell me how to convert date to milliseconds.
thanks,
ayathasSee milliseconds and time properties:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Date.html -
ORA-19587: error occurred reading 16384 bytes at block number 1
Hi,
I am getting the following error after I run rman hot backup.
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of delete command on ORA_DISK_1 channel at 09/11/2007 02:01:03
ORA-19587: error occurred reading 16384 bytes at block number 1
ORA-27091: unable to queue I/O
ORA-27069: attempt to do I/O beyond the range of the file
Additional information: 1
Additional information: 1
Can anyone please advise. thanksPardon me for not providing all the information.
OS - Solaris 9 64bit
RMAN Script:
#!/bin/ksh
# Script Name: rman_proddb_hot_bkp.sh
# Version: 1.0 01-JUN-07
# This script takes online backup of the database
# Uncomment for tracing
set -xv
# ~~~~~ set the variables ~~~~~ #
ORACLE_HOME=/u01/app/oraprd/product/10.2.0/db_1
ORACLE_BASE=/u01/app/oraprd
ORACLE_SID=proddb
DATE_TODAY=`date +%d-%m-%y`
# ~~~~~ set the enviroment ~~~~~ #
HOME=/export/home/oraprd
LOGNAME=oraprd
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/ccs/bin:/usr/openwin/bin:/usr/local/bin:/usr/dt/bin
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
SHELL=/usr/bin/ksh
export HOME LOGNAME
export ORACLE_HOME ORACLE_BASE ORACLE_SID
export DATE_TODAY
LOG_DIR=/var/local/logs
export LOG_DIR
# ~~~~~ Check if output file exists ~~~~~ #
cd ${LOG_DIR}
touch ${LOG_DIR}/rman_${ORACLE_SID}.${DATE_TODAY}_hot_bkp.log
chmod 755 ${LOG_DIR}/rman_${ORACLE_SID}.${DATE_TODAY}_hot_bkp.log
LOG_FILE=${LOG_DIR}/rman_${ORACLE_SID}.${DATE_TODAY}_hot_bkp.log
export LOG_FILE
# ~~~~~ start RMAN hot backup ~~~~~ #
rman target / nocatalog log=${LOG_FILE} <<EOF
run {
sql "alter system archive log current";
host 'sleep 30';
crosscheck backup;
crosscheck archivelog all;
backup database plus archivelog tag "manual_hot_bkp_on_${DATE_TODAY}";
delete noprompt expired backup;
delete noprompt obsolete;
exit;
EOF
OS Disk space: df -h
Filesystem size used avail capacity Mounted on
/dev/md/dsk/d60 16G 4.0G 12G 26% /u02
/dev/md/dsk/d50 35G 25G 9.3G 73% /u01
/dev/md/dsk/d70 1.9G 1.3G 585M 70% /u03
/dev/md/dsk/d80 1.9G 1.3G 598M 69% /u04
/dev/md/dsk/d90 325G 77G 245G 24% /u05
/dev/md/dsk/d40 935M 210M 669M 24% /export/home
FRA is 32G and is 20G at this stage. I get an error when I try to delete obsolete;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of delete command on ORA_DISK_1 channel at 09/12/2007 06:56:21
ORA-19587: error occurred reading 16384 bytes at block number 1
ORA-27091: unable to queue I/O
ORA-27069: attempt to do I/O beyond the range of the file
Additional information: 1
Additional information: 1 -
How to convert date from "yyyymmdd" to "MM/DD/YYYY" format
1. I have one BLDAT field in my internal table.
its getting updated from input file.
2. The value in the input file is like yyyymmdd.
So the internal table field is filled like this
"YYYYMMDD".
3. After this,I have to compare this internal table
field with BSAD table.
4. The BLDAT field in BSAD table is in the format of
"MM/DD/YYYY".
5. the BLDAT field is having diff format in internal table and BSAD table.So I am unable to check this value.
How to convert it as like the BSAD table format."MM/DD/YYYY" format.
Thanks in advance!!Using the WRITE statement
data: gd_date(10). "field to store output date
* Converts date from 20020901 to 09.01.2002
write sy-datum to gd_date mm/dd/yyyy.
OR u can
CONCATENATE gd_date+4(2) gd_date+6(2) gd_date+0(4)
into gd_date seperated by '/' .
Hope this helps.
Kindly reward points and close the thread for the
answer which helped u OR get back with queries.
Maybe you are looking for
-
What are the APN values for Blackberry 9630 Tour?
I have an application to communicate with my server, what are the values I need to set the APN Settings?
-
This morning I updated my iphone 5 to ios 6.1 and everything is fine except most of my contacts are gone. The text messages and calls are still listed, but with phone numbers and no names. I went into my icloud and they are deleted from there too. Ho
-
Web links in .pdfs inoperable- "Acrob. could not run the browser"
I keep my Adobe Reader updated often, but I've been experiencing a severe inconsistency with the ability to open a (FFox) web page by clicking a link given by the author of any given .pdf., embedded in it. Sometimes it works and opens up the new FFox
-
Schedule to restart a managed server
Hi Is there anyway we can make a managed server restart on a specified day in a week. I am using the AS/400 as the backend and after we IPL the AS400 during the weekend , the application stops working. If I restart the server , it will work . So i wa
-
Ringer Sound doesn't work for phone calls.
I can't get my iPhone 4S sound to work for receiving phone calls. Sound selected along with vibrate for phone calls. Miss calls everytime. Volume turned up and turned on.