How to find out whether an object can be converted into a Long?

Hi,
I am facing a problem which can be summarized by the following. Let's imagine the following method:
public static int MyCompare(Object anyObj) throws Exception {
    Long X = new Long(3);
    if (anyObj "can be converted into a Long") {
        Long MyConv = anyObj;
        return X.compareTo(MyConv);
    } else {
        throw new Exception("No success");
}My issues are i) that I don't know how to write the proper test to check whether the anyObj parameter can be conveted into a Long and ii) How do I convert anyObj into a Long properly?
The method should not return an Exception in the following cases:
int a1 = 33;
long a2 = 44;
MyCompare(a1);
MyCompare(a2);Can anyone help? Thanks !
J.

Hi,
I have tried to test the suggestion with the following code:
public class MainLong {
    public static void main(String[] args) {
        int i = 33;
        long j = 44;
        Long k = new Long(55);
        String l = "Trulu";
        System.out.println(MyCompare(i));
        System.out.println(MyCompare(j));
        System.out.println(MyCompare(k));
        System.out.println(MyCompare(l));
    public static int MyCompare(Object inObj) {
        Long Dummy = new Long(30);
        if (inObj instanceof Long) {
            Long Temp = (Long) inObj;
            return Dummy.compareTo(Temp);
        } else {
            return Integer.MIN_VALUE;
}and I got the following output:
-2147483648
-1
-1
-2147483648which is all fine except for the call with an int, it should return -1.
The above are example of objects which can be passed as a parameter to the function. I bet I should test for (anyObj instanceof INTEGER), correct?
Thanks,
J.

Similar Messages

  • How to find out whether my Iphone 3Gs is officlially unlocked ( factory unlocked ) or "made" unlocked ? Can I upgrade its OS to OS 5 even if my phone is "made" unlocked ? how to up gared its OS ? are there any better ways to do it ?

    How to find out whether my Iphone 3Gs (OS version 3.1.3) is officlially unlocked ( factory unlocked ) or "made" unlocked ? Can I upgrade its current OS 3.1.3 to OS 5 even if my phone is not officlially unlocked ? how to up grade its OS ? what are there any better ways to do it ?
    Thanks,
    PRANAJ

    Depends wher you obtained the iPhone from and it's original supplier
    If the iPhone is an authorised unlock ( approved by the carrier) or was
    purchased from Apple as an unlocked iPhone  updating the iOS
    will have no effect on the iPhone and it's lock status
    HOWEVER if the software has been tampered with to remove the lock,
    updating the iOs will lock the iPhone back to the original carrier who holds the lock
    To find out the status of your iPhone  you could call Apple support
    and they may tell you if the iPhone is locked or not and if it is which carrier

  • How to find out, whether any invoice is having header text or not.

    HI all,
    How to find out, whether any invoice is having header text or not. wheich table we have to refer.
    Thanks
    mahaboob

    Hi,
    You need to use FM READ_TEXT.
    First you have to determine what text Object/ID/Language you want to read (you can have N text objects for an invoice header).
    The easiest way to do this is to have an example document with the text you want to read.
    For example in VF03.
    1-Goto->Header->Header Texts.
    2-Click on the text you want to read
    3-Double click on the text (Right side box) This will take you
    4-Goto->Header
    This will give you the data you need to use in the READ_TEXT F.M.

  • How to find out whether the system user is a vendor or a purchaser

    Hi,
    I am working in SRM 5.0. I have a requirement that some fields of Bid invitation can be visible by purchaser but not to bidder.
    How to find out whether the system user (user id though which system logged in) is a vendor or a purchaser. Kindly help me to resolve this issue.
    Sushmita Singh

    check his role.
    is surrogate bidding available for that bidder.
    via surrogate bid , purchaser can submit bid on behalf of the bidder.
    masa is correct
    pposa_bbp - search via user . so he might be  a purchaser.
    maintain business partner -supply your bidder bp number -edit
    go to bidder data .Under bidder data you must flag "PERMIT PROXY BIDDING"
    regards
    Muthu
    br
    muthu

  • How to Find Out whether Standard IDOC is Availabl for  Transaction ?

    Hi,
        We are having SAP implementation 4.7E IS-OIL. We would like to know how to find out whether is there any Standard IDOC is Available for the SAP Transaction.
    Particularly for IS-Oil related transaction. e.g Load Confiramtion. T-code - O4G1.
        From a Given Transaction code is there any link which can tell whether IDOC is Present or not.
         Kindly help me.
    Regards,
    Umesh

    check for transaction....we41 and we42..
    check for proper process code...then check in we57,we81 and we82..
    also u can search in google..
    UMESH note that u need some fucntional exp for working in IDOC...try to crack yr head ..give time..n u ll get to know the things soon..as there is no defined standards to work in idocs..
    for more info u can ask me for [email protected]
    best regards
    Message was edited by:
            Madan Gopal Sharma

  • How to find out whether it is shared Appl_top?

    How to find out whether it is shared Appl_top?

    Hi,
    In a Shared APPL_TOP installation, the APPL_TOP and the COMMON_TOP file systems are installed on a shared disk resource mounted to each node in the system. These nodes can be used to provide standard application tier services, such as Forms, Web, and Concurrent processing. Any changes made in the shared APPL_TOP file system are immediately visible on all nodes.
    Note that each node continues to have a separate Applications techstack installation.
    I have given the concept of shared Appl_TOP , so that you can understand "How to find out whether it is shared Apll_TOP".
    Hope, this will help you.

  • How to find out whether a particular changed by some user

    Hi gurus,
                I am just trying to figure it out how to find out whether a particular user has changed a particular table or not. In other words table changes history. If any of you know about it please let me know.
    Thankyou
    Jason

    Jason,
      Ajay mentioned changes to Table not for Data. If you are looking for Changes to Table Data... you need to check System Log SM21. check for that perticular period.
    Nagesh Ganisetti.
    Assign points if it helps.

  • How to find out, whether an input document of a process is IRM-protected?

    Having an LiveCycle process with an input variable of type document.
    How to find out, whether the document is a standard PDF or an IRM-protected PDF?
    Thanks,
    Dilettanto

    Really no way to tell from a given PDF-file, whether it is IRM-protected?

  • How to find out whether the transaction logs are being truncated or not

    Hi,
    We are using Veritas Backup tool for Backups and restores on our MS SQL 2000.
    One of our Veritas Tech has disabled the Truncation of Transaction Log Backup using the Job setup in Veritas. We want to confirm whether the Truncation is happening or not. I don't see any difference in the Transaction Log file size.
    How to find out whether truncation is active or not?
    Thanks
    Vijay

    Hello Vijay,
    On MSSQL truncation of transaction log does not shrink the size of the transaction log. It simply removes the content within the transaction log and writes it to the backup.
    Meaning the free percentage within the transaction log will increase.
    If you want to Resize the transaction log size, you need to do something else.
    The shrinking procedure is given here:
    http://support.microsoft.com/kb/907511
    Regards,
    Siddhesh

  • How to find out whether USER-EXIT is active or not

    Hello!
    How can I  find out whether USER-EXIT is active or not ?
    I set a break-point at these points and nothing happens
    if I want save my daocument ???
    Why
    PERFORM USEREXIT_SAVE_DOCUMENT.
    PERFORM USEREXIT_SAVE_DOCUMENT_PREPARE.
    Ragards
    Ilhan

    Hi Ilhan
    The easiest way, I guess, is by going to transaction SMOD, sticking in your enhancement name and pressing the test button.
    When placing breakpoints, don't use <b>Breakpoints > Breakpoint at > Statement...</b> and enter
    PERFORM USEREXIT_SAVE_DOCUMENT
    because you won't get any hits since the function module names are stored dynamically.
    Rather use <b>Breakpoints > Breakpoint at > Function Module...</b> and enter
    USEREXIT_SAVE_DOCUMENT
    for a better chance of hitting the breakpoint.
    Cheers
    Lyal
    Message's terrible grammar was edited by:
            Lyal Schumann

  • How to find out whether a program is running in Hyper-V virtual machine or not?

    If I want to make a program which only running in Hyper-V virtual machine, how can I find out whether
    the program is running in Hyper-V  virtual machine or not?

    https://gallery.technet.microsoft.com/scriptcenter/Determine-if-a-computer-is-cdd20473
    http://social.technet.microsoft.com/wiki/contents/articles/942.hyper-v-how-to-detect-if-a-computer-is-a-vm-using-script.aspx
    http://www.grouppolicy.biz/2014/01/how-to-target-group-policy-to-virtual-computers/
    Mike Crowley | MVP
    My Blog --
    Baseline Technologies

  • How to find out, whether win 2003 is sick ?

    Hello together,
    I am running some SAP NW 7.0  Application-Server (Java+Abap) on Windows Server 2003  64bit in front to a central instance on a host  IBM System i with DB2.
    I don't have much knowhow in Windows Servers and want to know, how can I find out whether the windows server is running good.
    On which values (perhaps Task Manager) should I keep an eye on?
    best regards
    Carsten Schulz

    HI,
    you can get all information i.e memory,cpu,hdd space by running st06 /st06n
    How to watch the net speed to the central instance?
    i can't get exactly what you want to know
    but you can perform developer trace on work process running on application server using sm50 -> process ->trace -> display file look for error.
    you get buffer related info. by running tcod -st02  if required you can change the relavant parameter in instance profile
    you can get memory consume by user tranasaction  by running sm04 ->goto->memory
    you can get responce time of application server by smlg -> goto -> load distribution
    regards,
    kaushal

  • How to find out whether material is tie to a BOM

    Hi everyone,
    I would like to know how do i find out whether a particular material is tied to BOM (as in is it part of a BOM structure)?

    Hi Bernard,
    You can use this FM <b>CS_WHERE_USED_MAT</b>.
    call function 'CS_WHERE_USED_MAT'
      exporting
       datub                      = sy-datum
       datuv                      = sy-datum
       matnr                      = wa_matnr
       werks                      = wa_werks
      importing
        topmat                     = i_topmat
      tables
        wultb                      = i_wultb
        equicat                    = i_equicat
        kndcat                     = i_kndcat
        matcat                     = i_matcat
        stdcat                     = i_stdcat
        tplcat                     = i_tplcat
      exceptions
        call_invalid               = 1
        material_not_found         = 2
        no_where_used_rec_found    = 3
        no_where_used_rec_selected = 4
        no_where_used_rec_valid    = 5
        others                     = 6.
    Hope this will help.
    Regards,
    Ferry Lianto

  • How to find out if an object belongs to young or tenured generation

    Hi,
    Working on an internal memory analysis tool (to embed in an application), and I wonder if anyone knows how to find out what part of the heap an object belongs to (young, tenured, permanent etc.). Since tools like VisualGC (both for JDK 1.4 and 1.5) seem to be able to discern between the objects in the heap, there must be a way to figure it out. Is there an API in JNI, JVMTI or JVMPI or anything else that provides this info?
    Thanks,
    Luc

    In Java 1.5 the Monitoring & Management API can tell you this. See J2SE 5.0 in a Nutshell

  • Buying iPod touch – how to find out whether it is a box with FW 1.1.3?

    Hi,
    does anyone know from which serial number on the iPod touch 16 GB model does come with firmware 1.1.3 or higher from factory?
    How can I find out whether firmware 1.1.3 is shipped on a sealed iPod touch in retail stores? Want to buy in Germany.
    Cheers
    Marc

    Hey!
    Marc,
    this is APPL's post BTW......
    "If the model number ends in a "b" it's got them.
    It's on the bottom of the box below the serial number."
    So good luck!
    Cheers,
    John

Maybe you are looking for

  • How to search for perticular substring in given string.

    Hi, Can any one tell me how to search for perticular substring in given string. example: I have to search for CA in given Order type it may be CA10 or CA15. Please Do the needful.

  • Dragging and copy and paste dont work.

    In the mail program I cannot drag e-mails to folders, and on any application I cannot copy or paste anything.

  • Coverting Word Documents to PDF

    I have been trying for over an hour to convert Word documents into PDF form without success!!  I downloaded the free trial for Adobe Pro and still I have not been able to use it.  If this is what a trial is like, why on earth would I want to purchase

  • ISE Guest Portal and one more SSID using internal accounts

    Hi Guys, I have two SSIDs on WLC, the first is related with ISE Guest Portal and the second is related with employee but i realize that the Guest user can access the employee SSID and employee accounts can access the Guest portal page. I guess this i

  • ExtendScript Toolkit - Object Model Viewer

    Hi all, I know there's not really a way around this but I'm curious if anyone knows why the Object Model Viewer in ExtendScript Toolkit doesn't have After Effects Object Model in the Browser dropdown?  It has it for Bridge, InDesign, Illustrator and