String object to Date object

Hi,
I have date as string object "22/04/2008". I want convert this string object to Date object as specified format (dd/MM/yyyy) only.
Please do the need full.
Thanks in Advance

kishoreyakkali wrote:
Hi,
I tried as follows
SimpleDateFormat strOutDt = new SimpleDateFormat("dd/MM/yyyy");
Date dateObj=strOutDt.parse(strTmp);
System.out.println("dateObj::::" + dateObj);
Output : Mon Apr 21 00:00:00 IST 2008 A date object is always a wrapper around a millisecond value. It does not contain any formatting information, so you should never print a Date object. You should always convert it to a String using SimpleDateFormat before you print.
Kaj

Similar Messages

  • Can we change data in string object.

    Can we change data in string object.

    Saw this hack to access the char[]'s in a String in another thread. Beware that the effects of doing this is possible errors, like incorrect hashCode etc.
    import java.lang.reflect.*;
    public class SharedString {
            public static Constructor stringWrap = null;
            public static String wrap(char[] value, int offset, int length) {
                    try {
                            if (stringWrap == null) {
                                    stringWrap = String.class.getDeclaredConstructor(new Class[] { Integer.TYPE, Integer.TYPE, char[].class });
                                    stringWrap.setAccessible(true);
                            return (String)stringWrap.newInstance(new Object[] { new Integer(offset), new Integer(length), value });
                    catch (java.lang.NoSuchMethodException e) {
                            System.err.println ("NoMethod exception caught: " + e);
                    catch (java.lang.IllegalAccessException e) {
                            System.err.println ("Access exception caught: " + e);
                    catch (java.lang.InstantiationException e) {
                            System.err.println ("Instantiation exception caught: " + e);
                    catch (java.lang.reflect.InvocationTargetException e) {
                            System.err.println ("Invocation exception caught: " + e);
                    return null;
            public static void main(String[] args) {
                    char[] chars = new char[] { 'l', 'e', 'v', 'i', '_', 'h' };
                    String test = SharedString.wrap(chars, 0, chars.length);
                    System.out.println("String test = " + test);
                    chars[0] = 'k';
                    chars[1] = 'a';
                    chars[2] = 'l';
                    chars[3] = 'l';
                    chars[4] = 'a';
                    chars[5] = 'n';
                    System.out.println("String test = " + test);
    } Gil

  • Sporadically getting error "string or binary data would be truncated" in SQL server 2008 while inserting in a Table Type object

    I am facing a strange SQL exception:-
    The code flow is like this:
    .Net 4.0 --> Entity Framework --> SQL 2008 ( StoredProc --> Function {Exception})
    In the SQL Table-Valued Function, I am selecting a column (nvarchar(50)) from an existing table and (after some filtration using inner joins and where clauses) inserting the values in a Table Type Object having a column (nvarchar(50))
    This flow was working fine in SQL 2008 but now all of sudden the Insert into @TableType is throwing  "string or binary data would be truncated"  exception. 
    Insert Into @ObjTableType
    Select * From dbo.Table
    The max length of data in the source column is 24 but even then the insert statement into nvarchar temp column is failing.
    Moreover, the same issue started coming up few weeks back and I was unable to find the root cause, but back then it started working properly after few hours
    (issue reported at 10 AM EST and was automatically resolved post 8 PM EST). No refresh activity was performed on the database.
    This time however the issue is still coming up (even after 2 days) but is not coming up in every scenario. The data set, for which the error is thrown, is valid and every value in the function is fetched from existing tables. 
    Due to its sporadic nature, I am unable to recreate it now :( , but still unable to determine why it started coming up or how can i prevent such things to happen again.
    It is difficult to even explain the weirdness of this bug but any help or guidance in finding the root cause will be very helpful.
    I also Tried by using nvarchar(max) in the table type object but it didn't work.
    Here is a code similar to the function which I am using:
    BEGIN
    TRAN
    DECLARE @PID
    int = 483
    DECLARE @retExcludables
    TABLE
        PID
    int NOT
    NULL,
        ENumber
    nvarchar(50)
    NOT NULL,
        CNumber
    nvarchar(50)
    NOT NULL,
        AId
    uniqueidentifier NOT
    NULL
    declare @PSCount int;
    select @PSCount =
    count('x')
    from tblProjSur ps
    where ps.PID
    = @PID;
    if (@PSCount = 0)
    begin
    return;
    end;
    declare @ExcludableTempValue table (
            PID
    int,
            ENumber
    nvarchar(max),
            CNumber
    nvarchar(max),
            AId
    uniqueidentifier,
            SIds
    int,
            SCSymb
    nvarchar(10),
            SurCSymb
    nvarchar(10)
    with SurCSymbs as (
    select ps.PID,
                   ps.SIds,              
                   csl.CSymb
    from tblProjSur ps
                right
    outer join tblProjSurCSymb pscs
    on pscs.tblProjSurId
    = ps.tblProjSurId
    inner join CSymbLookup csl
    on csl.CSymbId
    = pscs.CSymbId 
    where ps.PID
    = @PID
        AssignedValues
    as (
    select psr.PID,
                   psr.ENumber,
                   psr.CNumber,
                   psmd.MetaDataValue
    as ClaimSymbol,
                   psau.UserId
    as AId,
                   psus.SIds
    from PSRow psr
    inner join PSMetadata psmd
    on psmd.PSRowId
    = psr.SampleRowId
    inner join MetaDataLookup mdl
    on mdl.MetaDataId
    = psmd.MetaDataId
    inner join PSAUser psau
    on psau.PSRowId
    = psr.SampleRowId
                inner
    join PSUserSur psus
    on psus.SampleAssignedUserId
    = psau.ProjectSampleUserId
    where psr.PID
    = @PID
    and mdl.MetaDataCommonName
    = 'CorrectValue'
    and psus.SIds
    in (select
    distinct SIds from SurCSymbs)         
        FullDetails
    as (
    select asurv.PID,
    Convert(NVarchar(50),asurv.ENumber)
    as ENumber,
    Convert(NVarchar(50),asurv.CNumber)
    as CNumber,
                   asurv.AId,
                   asurv.SIds,
                   asurv.CSymb
    as SCSymb,
                   scs.CSymb
    as SurCSymb
    from AssignedValues asurv
    left outer
    join SurCSymbs scs
    on    scs.PID
    = asurv.PID
    and scs.SIds
    = asurv.SIds
    and scs.CSymb
    = asurv.CSymb
    --Error is thrown at this statement
    insert into @ExcludableTempValue
    select *
    from FullDetails;
    with SurHavingSym as (   
    select distinct est.PID,
                            est.ENumber,
                            est.CNumber,
                            est.AId
    from @ExcludableTempValue est
    where est.SurCSymb
    is not
    null
    delete @ExcludableTempValue
    from @ExcludableTempValue est
    inner join SurHavingSym shs
    on    shs.PID
    = est.PID
    and shs.ENumber
    = est.ENumber
    and shs.CNumber
    = est.CNumber
    and shs.AId
    = est.AId;
    insert @retExcludables(PID, ENumber, CNumber, AId)
    select distinct est.PID,
    Convert(nvarchar(50),est.ENumber)
    ENumber,
    Convert(nvarchar(50),est.CNumber)
    CNumber,
                            est.AId      
    from @ExcludableTempValue est 
    RETURN
    ROLLBACK
    TRAN
    I have tried by converting the columns and also validated the input data set for any white spaces or special characters.
    For the same input data, it was working fine till yesterday but suddenly it started throwing the exception.

    Remember, the CTE isn't executing the SQL exactly in the order you read it as a human (don't get too picky about that statement, it's at least partly true enough to say it's partly true), nor are the line numbers or error messages easy to read: a mismatch
    in any of the joins along the way leading up to your insert could be the cause too.  I would suggest posting the table definition/DDL for:
    - PSMetadata, in particular PSRowID, but just post it all
    - tblProjectSur, in particularcolumns CSymbID and TblProjSurSurID
    - cSymbLookup, in particular column CSymbID
    - PSRow, in particular columns SampleRowID, PID,
    - PSAuser and PSUserSur, in particualr all the USERID and RowID columns
    - SurCSymbs, in particular colum SIDs
    Also, a diagnostic query along these lines, repeat for each of your tables, each of the columns used in joins leading up to your insert:
    Select count(asurv.sid) as count all
    , count(case when asurv.sid between 0 and 9999999999 then 1 else null end) as ctIsaNumber
    from SurvCsymb
    The sporadic nature would imply that the optimizer usually chooses one path to the data, but sometimes others, and the fact that it occurs during the insert could be irrelevant, any of the preceding joins could be the cause, not the data targeted to be inserted.

  • Why should I wrap String objects in a class for my HtmlDataTable?

    Hi,
    Let me describe a basic scenario in which my problem occurs. I have a backing bean and a JSP. The JSP gets a List<String> which is displayed inside a column in an editable HtmlDataTable. Each row in the data table has a UICommandLink that can perform an update to the value in the first column. Hence, the table only has two columns: one input field and one command link.
    My problem is this: When I try to execute HtmlDataTable#getRowData() when the command link is pressed, the updated values are not retrieved, but instead the values that have been in the input field before any changes were made. However, if I instead wrap my List objects inside a StringWrapper class (with a String property and appropriate getters and setters) such that I have a List<StringWrapper>, the problem does not occur. Why is this and is there any way to avoid it?
    I typed out some code to illustrate my scenario. Example 1 is where the table displays a list of String objects and Example 2 is where the table displays a list of StringWrapper objects.
    Example 1: [http://pastebin.com/m2ec5d122|http://pastebin.com/m2ec5d122]
    Example 2: [http://pastebin.com/d4e8c3fa3|http://pastebin.com/d4e8c3fa3]
    I'll appreciate any feedback, many thanks!

    Hi,
    Let me describe a basic scenario in which my problem occurs. I have a backing bean and a JSP. The JSP gets a List<String> which is displayed inside a column in an editable HtmlDataTable. Each row in the data table has a UICommandLink that can perform an update to the value in the first column. Hence, the table only has two columns: one input field and one command link.
    My problem is this: When I try to execute HtmlDataTable#getRowData() when the command link is pressed, the updated values are not retrieved, but instead the values that have been in the input field before any changes were made. However, if I instead wrap my List objects inside a StringWrapper class (with a String property and appropriate getters and setters) such that I have a List<StringWrapper>, the problem does not occur. Why is this and is there any way to avoid it?
    I typed out some code to illustrate my scenario. Example 1 is where the table displays a list of String objects and Example 2 is where the table displays a list of StringWrapper objects.
    Example 1: [http://pastebin.com/m2ec5d122|http://pastebin.com/m2ec5d122]
    Example 2: [http://pastebin.com/d4e8c3fa3|http://pastebin.com/d4e8c3fa3]
    I'll appreciate any feedback, many thanks!

  • Non-string objects as parameters to an applet

    how can i pass non-string objects as parameters to an applet?
    thanks in advance...

    those are some objects that i wroteThen, you could use Class.forName() method for your string parameters.
    If you get the classes, then you can call newInstance() method on them to get objects.
    Alternative way could be using your string parameter as index or keys for some
    data structures that contains ready-made objects.

  • Why jvm maintains string pool only for string objects why not for other objects?

    why jvm maintains string pool only for string objects why not for other objects? why there is no pool for other objects? what is the specialty of string?

    rp0428 wrote:
    You might be aware of the fact that String is an immutable object, which means string object once created cannot be manipulated or modified. If we are going for such operation then we will be creating a new string out of that operation.
    It's a JVM design-time decision or rather better memory management. In programming it's quite a common case that we will define string with same values multiple times and having a pool to hold these data will be much efficient. Multiple references from program point/ refer to same object/ value.
    Please refer these links
    What is Java String Pool? | JournalDev
    Why String is Immutable in Java ? | Javalobby
    Sorry but you are spreading FALSE information. Also, that first article is WRONG - just as OP was wrong.
    This is NO SUCH THING as a 'string pool' in Java. There is a CONSTANT pool and that pool can include STRING CONSTANTS.
    It has NOTHING to do with immutability - it has to do with CONSTANTS.
    Just because a string is immutable does NOT mean it is a CONSTANT. And just because two strings have the exact same sequence of characters does NOT mean they use values from the constant pool.
    On the other hand class String offers the .intern() method to ensure that there is only one instance of class String for a certain sequence of characters, and the JVM calls it implicitly for literal strings and compile time string concatination results.
    Chapter 3. Lexical Structure
    In that sense the OPs question is valid, although the OP uses wrong wording.
    And the question is: what makes class Strings special so that it offers interning while other basic types don't.
    I don't know the answer.
    But in my opinion this is because of the hybrid nature of strings.
    In Java we have primitive types (int, float, double...) and Object types (Integer, Float, Double).
    The primitive types are consessons to C developers. Without primitive types you could not write simple equiations or comparisons (a = 2+3; if (a==5) ...). [autoboxing has not been there from the beginning...]
    The String class is different, almost something of both. You create String literals as you do with primitives (String a = "aString") and you can concatinate strings with the '+' operator. Nevertheless each string is an object.
    It should be common knowledge that strings should not be compared with '==' but because of the interning functionality this works surprisingly often.
    Since strings are so easy to create and each string is an object the lack ot the interning functionality would cause heavy memory consumption. Just look at your code how often you use the same string literal within your program.
    The memory problem is less important for other object types. Either because you create less equal objects of them or the benefit of pointing to the same object is less (eg. because the memory foot print of the individual objects is almost the same as the memory footpint of the references to it needed anyway).
    These are my personal thoughts.
    Hope this helps.
    bye
    TPD

  • Where is String object in memory? and why?

    I read an article about String, it states:
    String str1 = new String("abc");
    the String object in the heap,
    String str2 = "abc";
    then String object will be in data segment?
    is the statement true? and why? it's a really interesting question, thx

    Thanks you so much for the great article!!
    cotton.m!!
    I can cheat on my assignment again, haha!
    strange
    Stepwise Refinement :|
    http://forum.java.sun.com//thread.jspa?threadID=5206258

  • Javascript Error! Error number: 45 error string: Objects is invalid line: 387, Line 428

    I am running Indesign CS3 on an XP computer. I installed a plugin for barcodes from teacup Software, Barcodemaker for Indesign CS3 win and this has crashed my Indesign CS3.
    Everytime I startup I get this Javascript error! Error number: 45 Error string: objects is invalid line: 387 I hit enter and iget the same message line: 428.
    The adobe knowledge base has a message http://kb.adobe.com/selfservice/viewContent.do?externalId=kb402389&sliceId=2
    I can't find the file Pluginconfig.txt on my computer to delte as suggested in this article. Can anyone help with this issue.
    I have uninstalled the plugin and I have try to repair/reinstall my copy of Indesigh CS3 version 5.0.4 but it still is not possible to use Indesign.
    Has anyone encoutered this problem? Can you tell me where to find this file Pluginconfig.txt.

    C:\Documents and Settings\[username]\Local Settings\Application Data\Adobe\InDesign\Version 5.0\Caches\InDesign Recovery
    This is a hidden folder, so you'll need to set Explorer to show hidden files if you haven't already. Start by just renaming the folder to _InDesign Recovery and it should rebuild on the next launch if this is going to work. If it doesn't work, you won't have lost anything.
    Might work even better if you were to try a system restore, however. Do you have a restore point from before the plugin was installed?
    Peter

  • Error accesing/using a String object.......

    Hi again folks!
    Well now I have other problem, I don?t know what's happening, but I have simple C++ program as shared object which retrieves information from a Database, with the query results it makes a single string with all the data retrieved.
    This C++ program is called by a Java program using JNI, but when my Java program receives the string and tries to parse it with the StringTokenizer object I get an error like this:
    SIGSEGV 11* segmentation violation
    si_signo [11]: SIGSEGV 11* segmentation violation
    si_errno [0]: Error 0
    si_code [1]: SEGV_ACCERR [addr: 0x45cb2448]
    stackbase=DFFFF0A0, stackpointer=DFFFD0CC
    Full thread dump:
    "SIGQUIT handler" (TID:0xdd300190, sys_thread_t:0x42020, state:R, thread_t:
    t@5, sp:0x0 threadID:0xdeaf0dd8, stack_base:0xdeaf0d6c, stack_size:0x20000) prio
    =0
    "Finalizer thread" (TID:0xdd3000d0, sys_thread_t:0x41fb8, state:CW, thread_t
    : t@4, sp:0x0 threadID:0xdebb0dd8, stack_base:0xdebb0d6c, stack_size:0x20000) pr
    io=1
    "main" (TID:0xdd3000a8, sys_thread_t:0x42908, state:R, thread_t: t@1, sp:0x0
    threadID:0x20a18, stack_base:0xdffff0a0, stack_size:0x800000) prio=5 *current t
    hread*
    ObjectFactory.createObject(Compiled Code)
    Test.main(Compiled Code)
    Registered Monitor Dump:
    PCMap lock: <unowned>
    Thread queue lock: <unowned>
    Name and type hash table lock: <unowned>
    String intern lock: <unowned>
    JNI pinning lock: <unowned>
    JNI global reference lock: <unowned>
    BinClass lock: <unowned>
    Class loading lock: owner "main" (0x42908, 1 entry)
    Java stack lock: <unowned>
    Code rewrite lock: <unowned>
    Heap lock: <unowned>
    Has finalization queue lock: <unowned>
    Finalize me queue lock: <unowned>
    Waiting to be notified:
    "Finalizer thread"
    Monitor cache expansion lock: <unowned>
    Monitor registry: owner "main" (0x42908, 1 entry)
    Abort (core dumped)
    I dont know if I have to do something special before use the String, what's happening?
    Any comment will be welcome.
    Thanks in advance.

    I hope this could help to clarify the scenario
    In a previous query I get the number of rows returned by the next query
    this number is stored at SQL_NUM_SEGS.arr variable. When I have the number of rows I reserve memory for the char array that I'm going to return with all the information.
    AC01_TRAMA=(char *)malloc(atol(SQL_NUM_SEGS.arr) * INT02_TAM_SEG);
    /*embedded PL/SQL code*/
    EXEC SQL DECLARE CUR_EMISORA CURSOR FOR
    SELECT rtrim(to_char(NUM_EMISORA)) || '|' || rtrim(SERIE) || '|' || EMISORA || '|' || STATUS FROM NUCL_EMISORA WHERE STATUS NOT LIKE 'BAJA';
    EXEC SQL OPEN CUR_EMISORA;
    The next lines of code generate a string like this:
    "UTIL0000|366|239|93-1|FINASA |VIGE|243|3-90|BONSER |VIGE|248|2-94|BONSER |VIGE|287|970403|GOBFED |VIGE|362|93-4|BANOBRA |VIGE|404|2-90|BONSER |VIGE|407|2-95|FINASA |VIGE|633|95|BANMEXI |VIGE|641|2-94|PROMEX |VIGE|645|1-95|FINASA |VIGE|647|1-96|FINASA |VIGE|660|92|BANORTE |VIGE|677|93-3|BANOBRA |VIGE|678|1-90|BIATLAN |VIGE|736|2-95|BONSER |VIGE|786|1-94|BNCI |VIGE|1007|021024|GOBFED |VIGE|1008|021121|GOBFED |VIGE|"
    this string is assigned to AC01_TRAMA(char pointer)and then I return this string in the next way:
    return ( (env)->NewStringUTF(AC01_TRAMA) );
    My java program is this:
    public class Monitor
    public native String consultaGeneral();
    static
    System.load("/afs/invermexico.com.mx/usr2/salponce/gustavo/jni/src_db/Monitor.so");
    public String getTrama()
         String strTrama=consultaGeneral();
    return strTrama;
    public static void main(String []args)
    String strEmisora, strNumEmisora, strStatus,strSerie;
    Monitor m=new Monitor();
    System.out.println(m.getTrama());
    /*java.util.StringTokenizer STk = new java.util.StringTokenizer(m.getTrama(),"|");
    while(objSTk.hasMoreTokens())     
    strEmisora = objSTk.nextToken();
    strNumEmisora = objSTk.nextToken();
    strStatus = objSTk.nextToken();
    strSerie = objSTk.nextToken();
    System.out.println("\n<------>\n"+ strEmisora+"\n"+strNumEmisora+"\n"+strStatus+"\n"+strSerie);
    }//while
    Well, this java program works fine but if I try to create an String tokenizer with it the program crashes, even if I assign the result into a new String object.
    I'm going to put all the code rigth here
    C++ program
    #include "ast_bd.h"
    #include "Monitor.h"
    #include <stdlib.h>
    #include <stdio.h>
    #include <strings.h>
    #include <jni.h>
    #define CHA01_NOMBRE_APP "UTIL0000"
    #define CHA02_FIN_DE_SEG "|"
    #define INT01_TAM_LONG 20
    #define INT02_TAM_SEG 52 /*52 BYTES; Tama�o de los 4 datos en conjunto*/
    Prop�sito :-Determinar cuales son las emisoras con estado de vigente
    o bloqueado.
    -Obtener los datos de una emisora espec�fica.
    -Actualizar los datos de una emisora espec�fica.
    JNIEXPORT jstring JNICALL Java_Monitor_consultaGeneral
    (JNIEnv *env, jobject obj)
    long LO01_STATUS=1;
    char CH01_NUM_SEGS[INT01_TAM_LONG];
    char AC01_TRAMA, AC02_SEG;
    EXEC SQL BEGIN DECLARE SECTION;
    VARCHAR SQL_NUM_SEGS[INT01_TAM_LONG],
    SQL_RESULT[INT02_TAM_SEG];
    EXEC SQL END DECLARE SECTION;
    EXEC SQL WHENEVER SQLERROR CONTINUE;
    open_db();
    EXEC SQL SELECT to_char(COUNT(1)) INTO:SQL_NUM_SEGS FROM NUCL_EMISORA WHERE STATUS NOT LIKE 'BAJA';
    LO01_STATUS = sqlca.sqlcode;
    if( !LO01_STATUS ) /*si todo sali� bien*/
    strcpy(CH01_NUM_SEGS,SQL_NUM_SEGS.arr);
    CH01_NUM_SEGS[SQL_NUM_SEGS.len]='\0';
    AC01_TRAMA=(char *)malloc(atol(SQL_NUM_SEGS.arr) * INT02_TAM_SEG);
    sprintf(AC01_TRAMA,"%s|%s|\0", CHA01_NOMBRE_APP, CH01_NUM_SEGS);
    EXEC SQL DECLARE CUR_EMISORA CURSOR FOR
    SELECT rtrim(to_char(NUM_EMISORA)) || '|' || rtrim(SERIE) || '|' || EMISORA || '|' || STATUS FROM NUCL_EMISORA WHERE STATUS NOT LIKE 'BAJA';
    EXEC SQL OPEN CUR_EMISORA;
    LO01_STATUS = sqlca.sqlcode;
    if( !LO01_STATUS ) /*si todo sali� bien*/
    do
    EXEC SQL FETCH CUR_EMISORA INTO :SQL_RESULT;
    LO01_STATUS = sqlca.sqlcode;/*Recuperamos el estado de la operacion fetch*/
    if( !LO01_STATUS )
    AC02_SEG=(char *)malloc(SQL_RESULT.len);
    strcpy(AC02_SEG,SQL_RESULT.arr);
    AC02_SEG[SQL_RESULT.len]='\0';
    strcat(AC01_TRAMA,AC02_SEG);
    strcat(AC01_TRAMA,CHA02_FIN_DE_SEG);
    }/*if fetch correcto*/
    else
    LO01_STATUS=1;
    }while(!LO01_STATUS);
    EXEC SQL CLOSE CUR_EMISORA;/*Cerramos el cursor*/
    Si no se recuperaron registros, se indicara en el numero de segmentos
    al inicio de la trama.
    }/*if open cursor*/
    }/*if conteo*/
    puts(AC01_TRAMA);
    return ( (env)->NewStringUTF(AC01_TRAMA) );
    }/*consulta_general*/
    Java programs
    public class Monitor
    public native String consultaGeneral();
    static
    System.load("/afs/invermexico.com.mx/usr2/salponce/gustavo/jni/src_db/Monitor.so");
    public String getTrama()
         String strTrama=consultaGeneral();
    return strTrama;
    public static void main(String []args)
    String strEmisora, strNumEmisora, strStatus,strSerie;
    Monitor m=new Monitor();
    System.out.println(m.getTrama());
    /*java.util.StringTokenizer STk = new java.util.StringTokenizer(m.getTrama(),"|");
    while(objSTk.hasMoreTokens())     
    strEmisora = objSTk.nextToken();
    strNumEmisora = objSTk.nextToken();
    strStatus = objSTk.nextToken();
    strSerie = objSTk.nextToken();
    System.out.println("\n<------>\n"+ strEmisora+"\n"+strNumEmisora+"\n"+strStatus+"\n"+strSerie);
    }//while
    Thank's

  • Regarding Month sorting in List Map String, Object

    Dear All,
    i have a list which is- List<Map<String, Object>> results . What i need is i want to sort the 'results ' .The values in results, when i tried to print it are
    RESULTS :{Apr 2009}
    RESULTS :{August 2008}
    RESULTS :{December 2008}
    RESULTS :{Feb 2009}
    RESULTS :{Jan 2009}
    RESULTS :{Jun 2009}
    RESULTS :{Mar 2009}
    RESULTS :{May 2009}
    RESULTS :{Nov 2008}
    RESULTS :{October 2008}
    RESULTS :{Sep 2008}
    i want to sort the values according to the month. like jan 2008,feb 2008 etc .
    Somebody please help .
    Thanks in advanced .

    sha_2008 wrote:
    The output sholud be june 2008,Dec 2008, Mar 2009. ie according to the increase order of monthsThat doesn't make it any clearer, in the example "June 2008" and "Mar 2009" are in the same map. Do you want that map to appear both before and after "Dec 2008" which doesn't make sense or are you expecting to restructure the data. If so, I would suggest you use a SortedMap like;
    List<Map<String,Object>> maps = ...
    SortedMap<String, Object> results = new TreeMap<String, Object>(dateComparator);
    for(Map<String, Object> map: maps)
       results.putAll(map);BTW: is there any good reason your dates are Strings instead of Date objects which are much easier to sort?

  • Conver String object into char

    Hi friends,
    I don't know how convert the String object into char(Primitive data type), using wrapper class?
    Kindly let me know.

    Have a look in the String API documentation for a method that returns an array of char.
    (It's not really what most people would describe as a wrapper class: that's more like converting a single char into an instance of Character.)

  • Why String Objects are immutable ?

    From the JLS->
    A String object is immutable, that is, its contents never change, while an array of char has mutable elements. The method toCharArray in class String returns an array of characters containing the same character sequence as a String. The class StringBuffer implements useful methods on mutable arrays of characters.
    Why are String objects immutable ?

    I find these answers quite satisfying ...
    Here's a concrete example: part of that safety is ensuring that an Applet can contact the server it was downloaded from (to download images, data files, etc) and not other machines (so that once you've downloaded it to your browser behind a firewall, it can't connect to your company's internal database server and suck out all your financial records.) Imagine that Strings are mutable. A rogue applet might ask for a connection to "evilserver.com", passing that server name in a String object. The JVM could check that this server name was OK, and get ready to connect to it. The applet, in another thread, could now change the contents of that String object to "databaseserver.yourcompany.com" at just the right moment; the JVM would then return a connection to the database!
    You can think of hundreds of scenarios just like that if Strings are mutable; if they're immutable, all the problems go away. Immutable Strings also result in a substantial performance improvement (no copying Strings, ever!) and memory savings (can reuse them whenever you want.)
    So immutable Strings are a good thing.
    The main reason why String made immutable was security. Look at this example: We have a file open method with login check. We pass a String to this method to process authentication which is necessary before the call will be passed to OS. If String was mutable it was possible somehow to modify its content after the authentication check before OS gets request from program then it is possible to request any file. So if you have a right to open text file in user directory but then on the fly when somehow you manage to change the file name you can request to open "passwd" file or any other. Then a file can be modified and it will be possible to login directly to OS.
    JVM internally maintains the "String Pool". To achive the memory efficiency, JVM will refer the String object from pool. It will not create the new String objects. So, whenever you create a new string literal, JVM will check in the pool whether it already exists or not. If already present in the pool, just give the reference to the same object or create the new object in the pool. There will be many references point to the same String objects, if someone changes the value, it will affect all the references. So, sun decided to make it immutable.

  • String Object info not getting displayed in outgoing referrences .

    Hi,
    Iam new to MAT and is in learning stage.
    Iam having a sample java program , whch has got String objects printed contunously . In order to take the heap dump while running itself , I am running this application for 2 minutes and in between Im taking the heap dump , but when analysed my java class , found that there is no entry for String objects under outgoing referrences of the java class from histogram.
    Please help me to find out why String object details are not present in outgoiing referrences for the java class.
    My Java Program,
    public class B{
    public static void main(String[] args) {
              //create Calendar instance
             Calendar now = Calendar.getInstance();
             System.out.println("Current time : "+ now.get(Calendar.HOUR_OF_DAY)+ ":" + now.get(Calendar.MINUTE)+ ":"+ now.get(Calendar.SECOND));
             int m = now.get(Calendar.MINUTE);
             B b = new B();
             b.print();
    public void print( int m2, Calendar now2){
               while ( (m2+2) >= now2.get(Calendar.MINUTE)){
                       String x = "xxxxxx";
                        System.out.println("String"+x);

    Hi,
    Do you mean this String object?
       String x = "xxxxxx";
    If so, then here the explanation. The String above is declared as a loca variable in the print method. I can't see any field pointing to it (neider an object insance is pointing to it, nor a static reference from the class).
    This local object will be in the heap as long as the method is running, and in the heap dump you will see such objects marked as GC roots. The type of this GC root will be <Java local> .
    Depending on the heap dump format, there may be also stack traces inside. If there are stack traces, you shold be able to see your object as referenced from the corresponding frame (the print method) in the Thread Stacks query.
    I hope this helps.
    Krum

  • How to create a xml file from String object in CS4

    Hi All,
    I want to convert a string object into an XML file using Javascript in Indesign CS4.
    I have done the following script. But it does not convert the namespaces for the xml elements with no value in it.
    var xml = new XML(string);
    The value present in string is "<level_1 xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>"
    When it is converted to xml, the value becomes "<level_1 xsi:nil="true"/>"
    On processing the above xml object, am getting an error like this "Uncaught JavaScript exception: Unbound namespace prefix."
    Kindly help.
    Thanks,
    Anitha

    Can you post more of the script?
    Are you getting the XML file from disk, or a string?

  • XML validation with DTD stored in String object

    Does anyone know if this is plausible......
    I am trying to validate some XML with a DTD... easy enough, right? The catch is that the dtd is NOT stored in a file somewhere and is also not declared in the XML to be validated. It is stored in a String object (as is the XML file to be validated).
    To clarify - I want to do something like this... but not sure how to incorporate the DTD.
    String dtd = // dtd definition here
    String xml = // xml text here (no URI at the top)
    SAXParserFactory factory = SAXParserFactory.newInstance();
    SAXParser parser = factory.newSAXParser();
    DefaultHandler handler = new DefaultHandler();  // DTD handler??
    parser.parse(new InputSource(new StringReader(xml.toString())), handler);any help would be greatly appreciated.
    thanks in advance,
    Terrance

    I guess it makes the most sense to make the dtd local to the xml. Therefore I would only have one string with both the xml contents and dtd contents. That is how I am going to approach this unless I hear something different.

Maybe you are looking for

  • Camera connector problem

    I have a Fujifilm F10 digital camera, iPod 4G with click wheel and camera connector. I have once successfully managed to transfer 6 photos from the camera to iPod with the connector. I just plugged them together and it did it automatically. I have no

  • Error in License Check

    Hi Friends , I am currently using SAP version 4.6c running on windows server 2003 and database running on SQL server. All the users at my site are getting the below message while login to production "Logon not possible Error in license check" I have

  • Exchange Server 2013 - AntiSpam Agents on Mailbox Server

    I'm interested in blocking additional spam messages coming through by use of the antispamagents.ps1 on my mailbox servers. Our current setup is the following: Internet> 3rd party email filter> Exchange Mailbox server My question is, if I turn on the

  • Icons... suddenly some are different....

    I use Dreamweaver by Adobe.  I noticed recently that all my .htm icons have the Opera (Browser) icon assigned to them.  If I switch the view setting to "Icons" they go away, but I prefer the list view or Cover flow view.  Anyway to revert to the old

  • Can i use wot on the iPad 2 web browser

    can i use web of trust on the i pad 2 browser