Java.text.SimpleDateFormat millisecond problem...

When I run this code:
java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat();
formatter.applyLocalizedPattern("yyyy-MM-dd HH:mm:ss.000000");
java.util.Date date1 = formatter.parse("2001-08-14 13:49:38.000000", new java.text.ParsePosition(0) );
System.out.println("Date 1 = " + date1);
formatter.applyLocalizedPattern("yyyy-MM-dd HH:mm:ss.SSS000");
java.util.Date date2 = formatter.parse("2001-08-14 13:49:38.000000", new java.text.ParsePosition(0) );
System.out.println("Date 2 = " + date2);
The output is:
Date 1 = Tue Aug 14 13:49:38 GMT+01:00 2001
Date 2 = null
The only difference is in the localized pattern, date 1 is generated where milliseconds aren't in the localized pattern, date 2 is generated where milliseconds are in the localized pattern.
Why is date2 null????

Hi! When you use the second pattern, it appears that "yyyy-MM-dd HH:mm:ss.SSS000" is not an acceptable pattern. However, "yyyy-MM-dd HH:mm:ss.SSS" works. I'd hazard a guess that when you specify milliseconds, only three places are allowed.
If you used pattern #2 as you had specified originally, a java.text.ParseException is thrown. With the above modification, it works as expected.
Hope this helps!
Cheers!

Similar Messages

  • Java.text.SimpleDateFormat  with zones

    Hi,
    I have a log file which has a date format as below:
    20091224060656.000000+060
    Wondering if java.text.SimpleDateFormat would be able to parse it properly.I was seeing this API and it didnot have any exact syntax for parsing this kind of date format.
    Please let me know.
    Regards
    Sayan

    sayanb wrote:
    Hi,
    Thank you for the response.The problem is this is one our client's log file which we are trying to parse using the java.text.SimpleDateFormat from our own java application.
    Hence not sure about +060. I guess the part after the . represent the zone , please correct me.But +060 not sure what this means and I dont think java.text.SimpleDateFormat has a way to parse this.
    Please let me know your comments.Uhm, you need to "tell" SimpleDateFormat what the format is, if you don't know how to interpret the format, how are you going to be able to configure SimpleDateFormat. Contact your "client" and make sure you understand the format, then look at the API docs for SimpleDateFormat and hammer out a pattern string for that format. (But I would assume that the "part after the dot" is second fragments (smaller than milliseconds but larger than nanoseconds, about half-way between, what the name for that is, I'm not sure), and that the part with the "plus" is the timezone, probably +060 is the same as +0600.) IOW, you will probably have to "preprocess" the string removing the last three digits before the "plus" and adding a 0 to the end, but that is only a guess.

  • HOWTO improve java.text.SimpleDateFormat.parse() performace?!!

    I am using SimpleDateFormat to parse the dates. The dates I am parsing have the time zone in format "+0500". So I am using the "z" format to parse it.
    After doing some CPU profile tests, it turns out that I am spending 33% of my entire processing time in parsing the time zones!!! Which is obviously too much time. Is there a way to improve performance on the time zone parsing? I made sure that only one SimpleDateFormat object is created when my application is initialized and I only use the parse() method repeatedly - so that the initialization cost would remain minimum.
    Also are there any other implementations of java.text.DateFormat which will perform better?
    Any help greatly appreciated.
    Thanks,
    Yash

    Are you using "z" or "Z". Upper case is right one.

  • Java.text.SimpleDateFormat.parse()

    This method does too much than I expected, say:
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    Date d = sdf.parser("00/00/0000");The d would be 1999, Nov. 30.
    After hacked the source code and some testing, I found it will roll backward or forward to generate a date. So, 01/32/2000 would become Feb. 01 2000. But I don't think this is a good implementation, as I expect it could throw exceptions at runtime if the string is not a valid time sting. And it's very difficult to debug, since any digit could be parsed!
    I think you guys here know what's behind the scene and why it's implemented like this. Any idea? Do you agree that the parse method should throw an exception when the fields of a date string're out of range? Or am I missing something?
    Comments are welcomed, and duke dollars're ready for those good answers.

    change your code as follows at it will do what you expected in the first places:
    <code>
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    sdf.setLenient(false);
    Date d = sdf.parser("00/00/0000");
    </code>
    Spieler

  • Java.util.text.SimpleDateFormat.parse strange behavior

    Wow !
    if I parse "10/14/2002" I get "0/2/2003", that is, the month 14 is considered 12 (december) + 2 additional months and therefore february in the next year!!
    any idea ?
    Paolo Denti
    =============================
    public class Test {
    public static void main(String[] args) {
    java.util.Date testDate = null;
    java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("dd-MM-yyyy");
    try {
    testDate = formatter.parse("10-14-2002");
    catch (java.text.ParseException e) {
    System.out.println("Data scassata: " + e.getMessage());
    System.exit(1);
    System.out.println(testDate.toString());
    =================================
    prints "Mon Feb 10 00:00:00 CET 2003"

    Tryformatter.setLenient(false);if you do not want this behaviour.

  • Java.text.ParseException:Unparseable date

    Whilst using the DBMS_XMLSave.updateXML procedure I am having problems parsing a date which is the format dd/mm/yy
    I have tried to use the following procedure to set the date format :
    DBMS_XMLSave.setDateFormat(updCtx,'DD/MM/YY');
    Unfortunately it is not working, as the parser still does not recognise the date format, it seems to want the time element.
    please may somebody advise on some possible solutions

    The date formats must match java date formats not Oracle date formats. For a list of valid date formats please check http://java.sun.com/products/jdk/1.1/docs/api/java.text.SimpleDateFormat.html
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Satvir Ghag ([email protected]):
    Whilst using the DBMS_XMLSave.updateXML procedure I am having problems parsing a date which is the format dd/mm/yy
    I have tried to use the following procedure to set the date format :
    DBMS_XMLSave.setDateFormat(updCtx,'DD/MM/YY');
    Unfortunately it is not working, as the parser still does not recognise the date format, it seems to want the time element.
    please may somebody advise on some possible solutions<HR></BLOCKQUOTE>
    null

  • Zip created through java.util.zip but problem in windows XP compress folder

    Hi friends,
    I am a software developer ,working on java/j2ee.currently i am working in a document management software related to logistics.Here i am facing a problem at the time of open the zip file through windows XP's in built software called "Folder compress".It's creared through java.util.zip.zipoutputstream.but at time of open through xp compress folder software ,it's showing error that "you can't open this file , this file are protected for your computer security" , but when i trying to open it through winzip or winrar, it's not giving any problem.My also specefing the code snippet below :-
    ZipOutputStream zip =  null;
         FileOutputStream fileWriter = null;
              try
                   fileWriter = new FileOutputStream(destZipFile);
                   zip = new ZipOutputStream(fileWriter);
                   //required for XP compress
                   zip.setMethod(ZipOutputStream.DEFLATED);
                zip.setLevel(Deflater.DEFAULT_COMPRESSION); //use default level
              }catch (Exception ex){
                   ex.printStackTrace();
                   System.exit(0);
              addFolderToZip("", srcFolder, zip);
              try
                   zip.flush();
                   zip.close();
                   zip=null;
                   fileWriter.close();
                   fileWriter = null;
              }catch (Exception ex)
                   //ex.printStackTrace();
                   logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Zip folder processing");
              }I desperately looking for a help regarding this issue , if any body have any solution the please send at this forum.
    Thanks,
    Chiranjit

    this file working file for winzip or winrar there is no problem.i am also sending the whole code of that java file that can help you better.
    Program Name:     EdocRetrieveServiceSLBean.java
    Description:     EdocRetrieveService CMP Bean Class
    Classes:          EdocRetrieveServiceSLBean
    Package:          net.mlog.edoc.ejb.entity
    Modification History
    <CR No>          <Date>               <Modified By>               <Comments>
    Version 1.0     2005.12.01          Sutapa   Ray               Create
    /** The sequence of methods to be called.
       ===============================================================================================================================
       1. mlogOriginDocumentAudit(String argActionDetails,int argDocumentId,int argActionId,String argActionByUserId)
       2. mlogDestinationBatchDownload(Vector TREEDATA,String SessionIDVal,String argUserId)
              a) Start DIR --
              private  String DoFolder(String folderNname)
              b) Create the folder
              private String CreateFolder(String FolderName,String newFolderPath)
              c) Zip the folder
              private void zipFolder(String srcFolder, String destZipFile)
              d) Add folders to zip file
              private void addToZip(String path, String srcFile, ZipOutputStream zip)
              e) Add the srcFolder to the zip stream.
              private void addFolderToZip(String path, String srcFolder, ZipOutputStream zip)
              f) Delete Directory from server
              public boolean deleteDir(File dir) {
       3. mpsDocumentView(String argUserId,Integer[] argSfxFileId)
       4. mlogOriginDocumentView(int argDocumentId,String argUserId)
       5. findDocTypeForDocId(Integer argDocId) throws RemoteException;
    package net.mlog.edoc.ejb.session;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    import javax.ejb.CreateException;
    import javax.ejb.ObjectNotFoundException;
    import javax.ejb.FinderException;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.naming.Context;
    import javax.rmi.PortableRemoteObject;
    import java.rmi.RemoteException;
    //import lib for all entity beans
    import net.mlog.edoc.ejb.entity.IDocumentCMP;
    import net.mlog.edoc.ejb.entity.IDocumentCMPHome;
    import net.mlog.edoc.ejb.entity.IDocumentTypeCMP;
    import net.mlog.edoc.ejb.entity.IDocumentTypeCMPHome;
    import net.mlog.edoc.ejb.entity.IDocumentAuditCMP;
    import net.mlog.edoc.ejb.entity.IDocumentAuditCMPHome;
    //import lib for reader class of properties file
    import net.mlog.edoc.ejb.session.PropertiesFileReader;
    //import lib for user Define File class
    import net.mlog.edoc.ejb.Session.EFile;
    //import lib for SFXWebClient
    import net.mlog.edoc.webservice.sfxWeb.ISFXWebClientSLHome;
    import net.mlog.edoc.webservice.sfxWeb.ISFXWebClientSL;
    import java.sql.Date;
    import java.sql.Timestamp;
    import java.text.SimpleDateFormat;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipOutputStream;
    import java.util.zip.Deflater;
    import java.util.Vector;
    import java.util.Iterator;
    import java.util.Collection;
    import java.util.StringTokenizer;
    import java.util.Enumeration;
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.io.File;
    import java.io.InputStream;
    import java.io.IOException;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    //import lib for NGP Mail
    import javax.jms.Queue;
    import javax.jms.QueueConnectionFactory;
    import javax.jms.QueueConnection;
    import javax.jms.QueueSender;
    import javax.jms.QueueSession;
    import javax.jms.JMSException;
    import weblogic.jms.extensions.WLQueueSession;
    import weblogic.jms.extensions.XMLMessage;
    //import javax.mail.*;
    //import javax.mail.internet.*;
    //import lib for USI
    import com.msl.security.USIException;
    import com.msl.security.USIServerAPI;
    import com.msl.security.UserPolicyData;
    import net.msl.util.logging.MLogger;
    public class EdocRetrieveServiceSLBean implements SessionBean {
      private static final boolean VERBOSE = true;
      private SessionContext ctx;
      public void ejbActivate() {
      public void ejbRemove() {
      public void ejbPassivate() {
      public void setSessionContext(SessionContext ctx) {
        this.ctx = ctx;
      public void ejbCreate () throws CreateException {
      private static final MLogger logger;
      static
         logger = MLogger.getLogger(net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.class.getName(), "net/mlog/edoc/ejb/session/eDocRetrieveServiceMessagesXML");
    //*********************KEEPING AUDITS OF DOCUMENTS BY MLOG ORIGIN PEOPLE*******************************
    * <b>
    * Used for Auditing the user action.
    * </b>
    * This function is called from various functions of eDocController
    * <p>
    * @param  argActionDetails Gives the details of Action in document audit.
    * @param  argDocumentId gives the Document Id in Document Audit.
    * @param  argActionId Action Id in Document Audit.
    * @param  argActionByUserId User Id of the Docment Audit action.
    * @return Returns a boolean value. 1 for success, 0 for Failure.
    public boolean mlogOriginDocumentAudit(String argActionDetails,int argDocumentId,int argActionId,String argActionByUserId) throws RemoteException
         //NGP/JDK Logging
         boolean flag=false;
    try{
         //getting context of the server
         InitialContext documentAuditCMPInitialContext=getInitialContext();
         Object objDocumentAuditCMPRef=null;
         try{
              objDocumentAuditCMPRef=documentAuditCMPInitialContext.lookup("DocumentAuditCMPBeanJNDI");
         catch(Exception e)
              //NGP/JDK Logging if JNDI Not found
              //logger.log(Level.SEVERE, "{0} : JNDI not found : {1}",new Object[] {"MSG002","DocumentAuditCMPBeanJNDI"});
              logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","DocumentAuditCMPBeanJNDI not found");
         //find the maximum audit id in the Document_Audit table
         //Home interface reference of DocumentAuditCMP EJB
         //IDocumentAuditCMPHome iDocumentAuditCMPHomeRef=(IDocumentAuditCMPHome)PortableRemoteObject.narrow(objDocumentAuditCMPRef,IDocumentAuditCMPHome.class);
         IDocumentAuditCMPHome iDocumentAuditCMPHomeRef=(IDocumentAuditCMPHome)objDocumentAuditCMPRef;
         //Remote interface reference of DocumentAuditCMP EJB
         IDocumentAuditCMP iDocumentAuditCMPCreateRef=iDocumentAuditCMPHomeRef.create(new Timestamp(System.currentTimeMillis()),argActionDetails,argActionByUserId,new Integer(argActionId),new Integer(argDocumentId));
         //set flag to true if Document is audited
         flag=true;
    }//end of try
    catch(Exception expt)
         //logger.finer(expt);
         logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.CreateException","Exception in creating Document Audit record");
      return flag;
    //*********************BATCH DOWNLOAD OF DOCUMENTS BY MLOG ORIGIN PEOPLE*******************************
    * <b>
    * Used for Validating the documents.
    * </b>
    * This function is called from Struts
    * <p>
    * @param  TREEDATA Treeset obtained after search.
    * @param  SessionIDVal gives the Session Value Id.
    * @return Returns a boolean value. 1 for success, 0 for Failure.
    public byte[] mlogDestinationBatchDownload(Vector TREEDATA,String SessionIDVal,String argUserId) throws RemoteException
         //NGP/JDK Logging
         /*FileHandler handler = null;
        Logger logger=null;
         try
           PropertiesFileReader propertiesFileReaderRef=new  PropertiesFileReader();
            String logFile=propertiesFileReaderRef.getProperties("/edoc.properties","EDOC_LOG");
           handler = new FileHandler("eDoc.log",0,1, true);
           logger = Logger.getLogger("ErrorMsg");
           logger.addHandler(handler);
           logger.setLevel(Level.ALL);
        }catch(Exception excp)
             NGP/JDK Logging warning
             logger.log(Level.WARNING, "{0} : Unable to find Resource Bundle File : {1}",new Object[] {"MSG001","ErrorMsg"});
         //Remote interface reference of SFXWebClientSL
         ISFXWebClientSL iSFXWebClientSLRef=null;
         //Home interface reference of SFXWebClientSL
         ISFXWebClientSLHome iSFXWebClientSLHomeRef=null;
         Vector filePath=new Vector();
         byte[] fileContent=null;
         String eDocRoot="";
         String eDocPathMain="";
         String eDocPath="";
         File tempRootFileforDelete = null;
         if (TREEDATA.capacity() != 0 )
              String BLNODirPath="";
              String PONODirPath="";
              String SONODirPath="";
              // added for doc type level--2005.11.27--samar
              String docTypeDirPath="";
              String filepath="";
              try
                 PropertiesFileReader propertiesFileReaderRef=new  PropertiesFileReader();
                 filepath=propertiesFileReaderRef.getProperties("/edoc.properties","TEMP_FILE_DIR");
                 logger.finer("File Path:" +filepath);
              }catch(Exception excp)
                   excp.printStackTrace();
                   logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.IOException","TEMP_FILE_DIR property (edoc.properties) not found");
              eDocRoot=CreateFolder("eDocTemp",filepath+File.separator);
              // added for top level--2005.12.02--samar
              //eDocRoot=CreateFolder("eDocTemp",System.getProperty("user.home")+File.separator);
              //eDocPath=CreateFolder(SessionIDVal,eDocRoot+File.separator);
              Enumeration TREEDATAEn = TREEDATA.elements();               //Setting The Tree Folder
              String   BLNO="";
              String   PONO="";
              String   SONO="";
              String   DNO ="";
              while(TREEDATAEn.hasMoreElements())
                   StringTokenizer st = new StringTokenizer((TREEDATAEn.nextElement()).toString(),"_");
                   while (st.hasMoreTokens()) // Extract All the Fields Of Every Vector Element
                        BLNO = st.nextToken();          // CSBWNO
                        PONO = st.nextToken();         // PONO
                        SONO = st.nextToken();        // SONO
                        DNO = st.nextToken();          // DNO
                        eDocPathMain=CreateFolder(SessionIDVal,eDocRoot+File.separator);
                        eDocPath=CreateFolder("eDoc",eDocPathMain+File.separator);
                        BLNODirPath = CreateFolder(BLNO,eDocPath+File.separator);
                        PONODirPath = CreateFolder(PONO,BLNODirPath+File.separator);
                        SONODirPath = CreateFolder(SONO,PONODirPath+File.separator);
                        // added for doc type level--2005.11.27--samar
                        docTypeDirPath=CreateFolder(findDocTypeForDocId(new Integer(DNO)),SONODirPath+File.separator);
                        File tempRootFile=new File(eDocRoot);
                        tempRootFile.canWrite();
                        filePath.add(tempRootFile.getParent());
                        tempRootFileforDelete = tempRootFile;
                        //File tempeDocPathMainFile=new File(eDocPathMain);
                        //filePath.add(tempeDocPathMainFile.getParent());
                        //2005-12-01::code change for top level directory deletion
                        //File tempFile=new File(eDocPath);//BLNODirPath);
                        //filePath.add(tempFile.getParent());
                        filePath.add(eDocPathMain);
                        filePath.add(eDocPath);
                        filePath.add(BLNODirPath);
                        filePath.add(PONODirPath);
                        filePath.add(SONODirPath);
                        // added for doc type level--2005.11.27--samar
                        filePath.add(docTypeDirPath);
                        /* Access The Data from DataBase Temp Storage with Document Id And Store In This SO Folder */
                        /*Long Raw*/
                        try
                             InitialContext initialContext=new InitialContext();
                             int sfxid=0;
                             /*DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
                             OraclePooledConnection pc = new OraclePooledConnection("jdbc:oracle:thin:hr/hr@essoraclesvr:1521:essorcl","edoc","edoc");
                             Connection con=new DBCon().Connect();//pc.getConnection();
                             PreparedStatement pstm=con.prepareStatement("select SFX_FILE_ID from DOCUMENT where DOCUMENT_ID=?");
                             //getting context of the server
                             InitialContext documentCMPInitialContext=getInitialContext();
                             Object objDocumentCMPRef=null;
                             try{
                                  objDocumentCMPRef=documentCMPInitialContext.lookup("DocumentCMPBeanJNDI");
                             catch(Exception e)
                                   //logger.log(Level.SEVERE, "{0} : JNDI not found : {1}",new Object[] {"MSG002","DocumentCMPBeanJNDI"});
                                   logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","DocumentCMPBeanJNDI not found");
                             //Home interface reference of DocumentCMP EJB
                             //IDocumentCMPHome iDocumentCMPHomeRef=(IDocumentCMPHome)PortableRemoteObject.narrow(objDocumentCMPRef,IDocumentCMPHome.class);
                             IDocumentCMPHome iDocumentCMPHomeRef=(IDocumentCMPHome)objDocumentCMPRef;
                             IDocumentCMP documentCMPRef=null;
                             //Remote interface reference of DocumentCMP EJB
                             try{
                                  documentCMPRef=iDocumentCMPHomeRef.findByPrimaryKey(new Integer(DNO));
                             catch(Exception e)
                                  logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ObjectNotFound","Document Id not found");
                             /*pstm.setInt(1,Integer.parseInt(DNO));
                             ResultSet rs1=pstm.executeQuery();
                             if(rs1.next()){
                             sfxid=rs1.getInt(1);
                             sfxid=documentCMPRef.getSfxFileId().intValue();
                             logger.finer("sfxid==="+sfxid);
                             String strFile=documentCMPRef.getDocumentName().toString();
                             //SFX lookup
                             //InitialContext initialContext=new InitialContext();
                             Object sfxWebClient=null;
                             try{
                                    sfxWebClient=initialContext.lookup("SFXWebClientJNDI");
                             catch(Exception e)
                                  //NGP/JDK logging if JNDI not found
                                  //logger.log(Level.SEVERE, "{0} : JNDI not found : {1}",new Object[] {"MSG002","SFXWebClientJNDI"});
                                  logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","SFXWebClientJNDI not found");
                             iSFXWebClientSLHomeRef=(ISFXWebClientSLHome)PortableRemoteObject.narrow(sfxWebClient,ISFXWebClientSLHome.class);
                             iSFXWebClientSLRef=iSFXWebClientSLHomeRef.create();//SFXWebClient reference creation
                             if(iSFXWebClientSLRef!=null)
                                  //logger.finer("ffffffff---");
                                  int arrSFXFileId[]=new int[1];
                                  arrSFXFileId[0]=sfxid;
                                  Object objEFile[]=iSFXWebClientSLRef.retrieveDocument(argUserId,arrSFXFileId);
                                  if(objEFile.length>0)
                                       byte b[]=(byte[])objEFile[1];
                                       String f=strFile.substring(strFile.lastIndexOf(File.separator)+1,strFile.length());
                                       // changed(instead of SONODirPath now docTypeDirPath) for doc type level--2005.11.27--samar
                                       FileOutputStream fout=new FileOutputStream(docTypeDirPath+File.separator + f);
                                       //logger.finer("SONODirPath+File.separator + f---"+SONODirPath+File.separator + f);
                                       filePath.add(docTypeDirPath+File.separator + f);
                                       int j;
                                       for(j=0;j<b.length;j++)
                                            fout.write(b[j]);
                                       fout.close();
                                       //for auditing the document
                                       //logger.finer("Document download audited");
                                       boolean flagAudit=mlogOriginDocumentAudit("Document has been downloaded",Integer.parseInt(DNO),5,argUserId);
                                       //logger.finer("Audit complete"+flagAudit);
                                       if(logger.isFinerLoggable()) {
                                            logger.finer("Audit complete"+flagAudit);
                             //Delete after finish
                             tempRootFile.delete();
                         }catch(Exception e)
                             //e.printStackTrace();
                             logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Folder creation processing");
                        /* End Long Raw     */
                      }// end of while hasMoreTokens
               }// end of while hasMoreElements
         }else{ }
         /* Zip */
          try
              zipFolder(eDocPath+File.separator,eDocPath+".zip");
          }catch(Exception excp)
              ////logger.finer(excp.toString());
              logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Zip processing");
         // send the byte array for the file
         String fileName=eDocPath+".zip";
         try{
                   File file=new File(fileName);
                   InputStream is = new FileInputStream(file);
                   // Get the size of the file
                   long length = file.length();
                   // You cannot create an array using a long type.It needs to be an int type.
                   // Before converting to an int type,check to ensure that file is not larger than Integer.MAX_VALUE.
                   //Kept for future requirement if any
                   if (length > Integer.MAX_VALUE) {
                        // File is too large
                   // Create the byte array to hold the data
                    fileContent = new byte[(int)length];
                   // Read in the bytes
                   int offset = 0;
                   int numRead = 0;
                   while (offset < fileContent.length
                           && (numRead=is.read(fileContent, offset, fileContent.length-offset)) >= 0) {
                        offset += numRead;
                   // Ensure all the bytes have been read in
                   if (offset < fileContent.length) {
                        throw new IOException("Could not completely read file "+file.getName());
                   // Close the input stream and return bytes
                   is.close();
         }catch(Exception e){
          deleteDir(tempRootFileforDelete);
         //trying for deleting folder and zip file
         File file=new File(fileName);
         if(file.exists())
                 file.delete();
                 //logger.finer("File Deleted successfully");
         if(file.exists()){
                 //logger.finer("File Not Deleted ");
         /* File FileToDelete = new File(eDocPath+".zip");
         boolean  DelStatus1 = deleteDir(FileToDelete);
          //logger.finer("Deletion 1:"+DelStatus1 );
          File FolderToDelete = new File(eDocPath);
         boolean  DelStatus2 = deleteDir(FolderToDelete);
          //logger.finer("Deletion 2:"+DelStatus2);
          for(int index=filePath.size()-1;index>=0;index--)
               File delFile=new File(filePath.elementAt(index).toString());
               //logger.finer(delFile.getAbsolutePath());
               if(delFile.exists())
                    //logger.finer("Before delete---123");
                    //logger.finer("File Deleted========>"+delFile.delete());
                    //logger.finer("After delete---123");
                    //logger.finer(delFile.getAbsolutePath()+"-----------"+delFile.exists());
          return fileContent;
    /* ***************************Start DIR *********************/
    private  String DoFolder(String folderNname)
         File f;
         f = new File(folderNname);
         f.mkdir();                                                   // Create The Folder
       //f.deleteOnExit();                                  //R n D to Delete The zip folders only  */
         return(folderNname+File.separator);
    //to create the folder
    private String CreateFolder(String FolderName,String newFolderPath)
              String NewDir ="";
              NewDir=newFolderPath + FolderName;
              newFolderPath=DoFolder(NewDir);
              return(NewDir);
    //To zip the folder
    private void zipFolder(String srcFolder, String destZipFile)
         ZipOutputStream zip =  null;
         FileOutputStream fileWriter = null;
              try
                   fileWriter = new FileOutputStream(destZipFile);
                   zip = new ZipOutputStream(fileWriter);
                   //required for XP compress
                   zip.setMethod(ZipOutputStream.DEFLATED);
                zip.setLevel(Deflater.DEFAULT_COMPRESSION); //use default level
              }catch (Exception ex){
                   ex.printStackTrace();
                   System.exit(0);
              addFolderToZip("", srcFolder, zip);
              try
                   zip.flush();
                   zip.close();
                   zip=null;
                   fileWriter.close();
                   fileWriter = null;
              }catch (Exception ex)
                   //ex.printStackTrace();
                   logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Zip folder processing");
         //     File f2= new File(destZipFile);
    *  Write the content of srcFile in a new ZipEntry, named path+srcFile,of the zip stream
    *  The result is that the srcFile will be in the path folder in the generated archive.
    *  @param path          String, the relative path with the root archive.
    *  @param srcFile     String, the absolute path of the file to add
    *  @param zip          ZipOutputStram, the stream to use to write the given file.
    //the folders are added to zip file
    private void addToZip(String path, String srcFile, ZipOutputStream zip)
         File folder = new File(srcFile);
         //folder.deleteOnExit();
         if (folder.isDirectory()) {
              addFolderToZip(path, srcFile, zip);
         else {
              //Transfer bytes from in to out
              byte[] buf = new byte[1024];
              int len;
              FileInputStream in = null;
              try {
                   in = new FileInputStream(srcFile);
                   // void putNextEntry(ZipEntry e) Begins writing a new ZIP file entry
                   // and positions the stream to the start of the entry data.
                   zip.putNextEntry(new ZipEntry(path +File.separator+ folder.getName()));
                   while ((len = in.read(buf)) > 0)
                        zip.write(buf, 0, len);
              }catch (Exception ex){
                   ex.printStackTrace();
                   logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Adding to Zip Folder");
              }finally{
                   try
                        //2005-12-01::file pointer close
                        in.close();
                   }catch(Exception e){
                        e.printStackTrace();
                        logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Adding to Zip Folder");
         folder.delete(); //we addedd for DELETE
    * add the srcFolder to the zip stream.
    * @param path          String, the relatif path with the root archive.
    * @param srcFile     String, the absolute path of the file to add
    * @param zip          ZipOutputStram, the stream to use to write the given file.
    private void addFolderToZip(String path, String srcFolder, ZipOutputStream zip)
         File folder = new File(srcFolder);
         folder.canWrite();
         //folder.deleteOnExit();
         String fileListe[] = folder.list();
         try
              int i = 0;
              while (true)
              addToZip(path+File.separator+ folder.getName(), srcFolder+File.separator+fileListe, zip);
              i++;
         }catch (Exception ex)
         logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Naming after adding to Zip Folder");
    /* $$$$$$$$$$$$$$$$$           End Zipping               $$$$$$$$$$$$$$$ */
    /****************Start Of Deleting Directory from server***********/
    public boolean deleteDir(File dir) {
         // to see if this directory is actually a symbolic link to a directory,
         // we want to get its canonical path
         //- that is, we follow the link to the file it's actually linked to
         File candir;
         try {
              candir = dir.getCanonicalFile();
         } catch (IOException e) {
              return false;
         // a symbolic link has a different canonical path than its actual path,
         // unless it's a link to itself
         if (!candir.equals(dir.getAbsoluteFile())) {
              //this file is a symbolic link, and there's no reason for us to follow it,
              //because then we might be deleting something outside of the directory we were told to delete
              return false;
         // now we go through all of the files and subdirectories in the directory and delete them one by one
         File[] files = candir.listFiles();
         if (files != null) {
         for (int i = 0; i < files.length; i++) {
              File file = files[i];
              //file read only set false
              //in case this directory is actually a symbolic link, or it's empty,
              //we want to try to delete the link before we try anything
              boolean deleted = file.delete();
              if (!deleted) {
                   // deleting the file failed, so maybe it's a non-empty directory
                   if (file.isDirectory()) deleteDir(file);
                   // otherwise, there's nothing else we can do
         // now that we tried to clear the directory out, we can try to delete it again
         return dir.delete();
    /************End Of Deleting Directory *********************/
    private InitialContext getInitialContext() throws NamingException {
    try {
    return new InitialContext();
    } catch (NamingException ne) {
    //logger.finer("Please make sure that the server is running.");
    throw ne;
    //*****************************WEB SERVICE FILE RETRIEVE IMPLEMENTATION FOR MPS PEOPLE*************************************************
    * <b>
    * Used for Retrieval of a document.
    * </b>
    * This function is called from retrieveDocument function of MPStoEdocWebServiceSLBean.
    * <p>
    * @param argUserId User Id of the user who wants to retrieve the document
    * @param argSfxFileId[] Sfx File Id which gives the reference number of the document(s) in the SFX database.
    * @return Returns a one dimentional Object array containing a series of file name and file content of the retrieved documents.
    public Object[] mpsDocumentView(String argUserId,Integer[] argSfxFileId) throws RemoteException
         //NGP/JDK logging
         logger.finer("mpsDocumentView called--");
         try{
              argUserId=argUserId.toUpperCase();
         catch(Exception e)
              e.printStackTrace();
         logger.finer("mpsDocumentView argSfxFileId[0]--"+argSfxFileId[0]);
         Object[] searchResult=null;
         /*FileHandler handler = null;
    Logger logger=null;
         int finalIndex=0;
         try
    //PropertiesFileReader propertiesFileReaderRef=new PropertiesFileReader();
         //String logFile=propertiesFileReaderRef.getProperties("/edoc.properties","EDOC_LOG");
    //handler = new FileHandler("eDoc.log",0,1, true);
    //logger = Logger.getLogger("ErrorMsg");
    //logger.addHandler(handler);
    //logger.setLevel(Level.ALL);
    }catch(Exception excp)
         //NGP/JDK Logging warning
         //logger.log(Level.WARNING, "{0} : Unable to find Resource Bundle File : {1}",new Object[] {"MSG001","ErrorMsg"});
         logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","PurchaseOrderCMPBeanJNDI not found");
         Object objDocumentFile[]=null;
         ISFXWebClientSLHome iSFXWebClientSLHomeRef=null;
         ISFXWebClientSL iSFXWebClientSLRef=null;
         try{
              //Locating SFX WEB CLIENT SESSION BEAN
              InitialContext initialContext=new InitialContext();
              Object sfxWebClient=null;
              try{
                   sfxWebClient=initialContext.lookup("SFXWebClientJNDI");
              catch(Exception e)
                   //NGP/JDK Logging if JNDI not found
                   //logger.log(Level.SEVERE, "{0} : JNDI not found : {1}",new Object[] {"MSG002","SFXWebClientJNDI"});
                   logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","SFXWebClientJNDI not found");
              iSFXWebClientSLHomeRef=(ISFXWebClientSLHome)PortableRemoteObject.narrow(sfxWebClient,ISFXWebClientSLHome.class);
              //creation of SFX we client
              iSFXWebClientSLRef=iSFXWebClientSLHomeRef.create();
              int arrSFXFileId[]=new int[argSfxFileId.length];
              logger.finer("SFXWebClient created----");
              //holds the sequence of SFX file id in the array
              //EFile file=new EFile();
              //getting context of the server
              InitialContext documentCMPInitialContext=getInitialContext();
         Object objDocumentCMPRef=null;
         int docId=0;
         try{
              objDocumentCMPRef=documentCMPInitialContext.lookup("DocumentCMPBeanJNDI");
         catch(Exception e)
                   //NGP/JDK Logging if JNDI not found
                   //logger.log(Level.SEVERE, "{0} : JNDI not found : {1}",new Object[] {"MSG002","DocumentCMPBeanJNDI"});
                   logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","DocumentCMPBeanJNDI not found");
         //Home interface reference of DocumentCMP EJB
         //IDocumentCMPHome iDocumentCMPHomeRef=(IDocumentCMPHome)PortableRemoteObject.narrow(objDocumentCMPRef,IDocumentCMPHome.class);
              IDocumentCMPHome iDocumentCMPHomeRef=(IDocumentCMPHome)objDocumentCMPRef;
         //find the document id in the Document table from the SFx File Id
              for(int index=0;index<argSfxFileId.length;index++)
                   arrSFXFileId[index]=argSfxFileId[index].intValue();
                   logger.finer("mpsDocumentView arrSFXFileId[index]--"+arrSFXFileId[index]);
         logger.finer("For Document auditing----");
         //Remote interface reference of DocumentCMP EJB
         IDocumentCMP iDocumentCMPRef=iDocumentCMPHomeRef.findDocIdBySfxId(new Integer(arrSFXFileId[index]));
                   docId=iDocumentCMPRef.getDocumentId().intValue();
                   //for document audit
                   try{
                        boolean flagAudit=mlogOriginDocumentAudit("Document is Viewed",docId,5,argUserId);
                   catch(Exception e)
                        //logger.finer("Document cannot be audited----");
                        logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in audit processing");
              //call the retrieveDocument method for the above array of elements
              //Object[] tempObjDocumentFile=iSFXWebClientSLRef.retrieveDocument(argUserId,arrSFXFileId);
              //EFile file=new EFile();
              //for(int index=0;index<tempObjDocumentFile.length;index++){
              //     file= (EFile) tempObjDocumentFile[index];
              //     objDocumentFile[finalIndex++]=file.getDocFileName();
              //     objDocumentFile[finalIndex++]=file.getDocFileContent();
              objDocumentFile=iSFXWebClientSLRef.retrieveDocument(argUserId,arrSFXFileId);
              //EFile[] efileArray = (EFile[]) = objDocumentFile;
              searchResult = new Object[efileArray.length*2];
              for (int i=0;i<efileArray.length;i=i+2)
                   EFile currentFile = efileArray[i];
                   searchResult[i] = currentFile.getDocFileName();
                   searchResult[i+1] = currentFile.getDocFileContent();
              searchResult=iSFXWebClientSLRef.retrieveDocument(argUserId,arrSFXFileId);
         }//end of try
         catch(Exception expt)
              //logger.finer(expt);
              logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in retrieve from SFX");
         //if exception occurs returns null as per initilisation above
         //logger.finer("mpsDocumentView size--"+objDocumentFile.length);
         return searchResult;
    //**************************** FILE RETRIEVE IMPLEMENTATION FOR MLOG PEOPLE*******************************
    * <b>
    * Used for Retrieval of a document.
    * </b>
    * This function is called from struts.
    * <p>
    * @param argDocumentId Documnet Id which gives the ID of the document in the eDoc database..
    * @param argUserId User Id of the user who wants to retrieve the document
    * @return Returns a one dimentional Object array containing a series of file name and file content of the retrieved documents.
    public Object[] mlogOriginDocumentView(int argDocumentId,String argUserId) throws RemoteException
         //NGP/JDK Logging
         logger.finer("mlogOriginDocumentView called--");
         try{
              argUserId=argUserId.toUpperCase();
         catch(Exception e)
              //e.printStackTrace();
              logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in uppercase");
    //logger.finer("mlogOriginDocumentView-- argDocumentId---"+argDocumentId);
         /*FileHandler handler = null;
    Logger logger=null;
         try
    //PropertiesFileReader propertiesFileReaderRef=new PropertiesFileReader();
         //String logFile=propertiesFileReaderRef.getProperties("/edoc.properties","EDOC_LOG");
    //handler = new FileHandler("eDoc.log",0,1, tr

  • Java.text.ParseException :UnparseableDate

    Hi,
    Iam trying to convert a String into Date and that Date in to a customized Date format...,Here it is what iam doing..
    import java.util.*;
    import java.io.*;
    import java.text.*;
    public class str2date
    public static void main(String[] args)
    try
    String mystr="01-03-2003";
         SimpleDateFormat converttodt=new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
         java.util.Date mydt=converttodt.parse(mystr.trim());
         System.out.println("mydt"+mydt);
         String output=converttodt.format(mydt);
         System.out.println(output);
         catch(ParseException e)
         System.out.println(e.toString());
    Error:"java.text.ParseException :UnparseableDate 01-03-2003"
    Can any one help me out... URGENT...,
    Thanks in Advance
    Rao.

    Well, the problem is right in front of you. You're telling it the format of the date is going to be
    yyyy-MM-dd'T'hh:mm:ss
    and then you're giving it the date in a format of
    MM-dd-yyyy
    and wondering why it's not accepting it? If you want to input a date from one format and output it in another you need to create two SimpleDateFormat objects, one to parse the date from a String to a Date object, and a second (or reuse the first with a different parse string) to format the Date and output it as a String.

  • Parse Exception : java.text.ParseException: Unparseable date

    I have inherited a UDF in some mapping that on the whole, works okay...
    but it throws an error after mapping a few dates:
    Parse Exception : java.text.ParseException: Unparseable date: "2010-03-18T00:00:00.000Z"
    Parse Exception : java.text.ParseException: Unparseable date: "2010-03-23T23:59:00.000Z"
    Parse Exception : java.text.ParseException: Unparseable date: "2010-03-18T00:00:00.000Z"
    Parse Exception : java.text.ParseException: Unparseable date: "2010-03-23T23:59:00.000Z"
    Parse Exception : java.text.ParseException: Unparseable date: "2010-03-18T00:00:00.000Z"
    Parse Exception : java.text.ParseException: Unparseable date: "2010-03-23T23:59:00.000Z"
    the first few map okay...  then i get the exception.
    the UDF is as follows:
    public String convertDateTimeToUTC(String strDate, Container container) throws StreamTransformationException{
    AbstractTrace trace = container.getTrace();
    Date date=null;
    SimpleDateFormat sdfSource = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
    try{
    String dt = strDate;
    date = sdfSource.parse(dt);
    trace.addInfo("Local Date:"+date);
    SimpleDateFormat sdfDestination = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    strDate = sdfDestination.format(date);
    catch(ParseException pe){
    trace.addInfo("Parse Exception : " + pe);
    return strDate;
    can anyone see why this fails after successfully mapping a few fields???

    the first mapping works correctly...
    then we reuse the same fields to map to the additional segments.
    the context is correct as it is trying to pull the same fields in...  it just throw the error with the same data in the same UDF/Function Library but for different segments! :o(
    http://img199.imageshack.us/img199/3104/dateconversion.jpg
    as you can see from the screenshot above, the mapping works in the first instance, then fails on subsequent nodes.

  • Java.text.ParseException: Unparseable date: "2008-12-16 00:00:00"

    Dear All WebLogic Guru,
    Need your help about the error in our WebLogic Apps Server. Below is the related logs. Hope to hear from you soon.
    ========
    Log snippet:
    ========
    [15:48:02 ] [INFO] [NumberFormatException in TimesheetAddHandler:] null [delegate.helper.gbms.bulkcrg.timesheet.TimesheetOperatorAddHandler.perform(TimesheetOperatorAddHandler.java:77)]
    java.text.ParseException: Unparseable date: "2008-12-16 00:00:00"
    at java.text.DateFormat.parse(DateFormat.java:337)
    at ejb.sessionBeans.gbms.bulkcrg.timesheet.TimesheetOperatorEJB.getOpsDttm(TimesheetOperatorEJB.java:1647)
    at ejb.sessionBeans.gbms.bulkcrg.timesheet.TimesheetOperator_vn72b_EOImpl.__WL_invoke(Unknown Source)
    at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:40)
    at ejb.sessionBeans.gbms.bulkcrg.timesheet.TimesheetOperator_vn72b_EOImpl.getOpsDttm(Unknown Source)
    at delegate.helper.gbms.bulkcrg.timesheet.TimesheetOperatorAddHandler.perform(TimesheetOperatorAddHandler.java:383)
    at delegate.RequestManager.perform(RequestManager.java:85)
    at delegate.FrontController.processRequest(FrontController.java:241)
    at delegate.FrontController.doPost(FrontController.java:378)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at sg.com.jp.framework.sso.SingleSignOnFilter.doFilter(SingleSignOnFilter.java:121)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at sg.com.jp.util.xss.XssFilter.doFilter(XssFilter.java:57)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at uiServlet.jponlinecharge.TxnLogFilter.doFilter(TxnLogFilter.java:153)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)
    [15:48:02 ] [INFO] [ScreenManager] Screen ID [TimesheetOperatorViewSvlt] mapped to [JSP/gbms/bulkcrg/timesheet/TimesheetOP_details.jsp] [delegate.ScreenManager.nextScreen(ScreenManager.java:60)]
    [15:48:02 ] [INFO] Next Screen is : /JRPA(or ServletContext@27549577[app:47jrpa module:JRPA path:/JRPA spec-version:null],WebLogic Server 10.3.4.0 Fri Dec 17 20:47:33 PST 2010 1384255 Oracle WebLogic Server Module Dependencies 10.3 Thu Oct 28 06:03:12 PDT 2010 Oracle WebLogic Server on JRockit Virtual Edition Module Dependencies 10.3 Thu Sep 23 15:02:15 PDT 2010 )/JSP/gbms/bulkcrg/timesheet/TimesheetOP_details.jsp [delegate.FrontController.processRequest(FrontController.java:322)]
    [15:48:02 ] [DEBUG] 2nd funcName in doFilter = TimesheetOP_details [uiServlet.jponlinecharge.TxnLogFilter.doFilter(TxnLogFilter.java:83)]
    [15:48:02 ] [DEBUG] #########new admin framework ########## Function Code = [uiServlet.jponlinecharge.TxnLogFilter.doFilter(TxnLogFilter.java:92)]
    [15:48:02 ] [DEBUG] Function Code = [uiServlet.jponlinecharge.TxnLogFilter.doFilter(TxnLogFilter.java:108)]
    Status :S
    [15:48:03 ] [DEBUG] Contains Function: true TimesheetOperatorSuperAmend [tags.ACLTag.doAfterBody(ACLTag.java:132)]
    [15:48:03 ] [DEBUG] Contains Function: true TimesheetOperatorSuperDelete [tags.ACLTag.doAfterBody(ACLTag.java:132)]
    [15:48:03 ] [DEBUG] Contains Function: true TimesheetOperatorClose [tags.ACLTag.doAfterBody(ACLTag.java:132)]
    [15:48:31 ] [DEBUG] 2nd funcName in doFilter = TimesheetOperatorSuperAmend [uiServlet.jponlinecharge.TxnLogFilter.doFilter(TxnLogFilter.java:83)]
    [15:48:31 ] [DEBUG] Function Code = F27052 [uiServlet.jponlinecharge.TxnLogFilter.doFilter(TxnLogFilter.java:108)]
    [15:48:31 ] [DEBUG] Logged In?: true [delegate.helper.System.AuthenticationHandler.valid(AuthenticationHandler.java:571)]
    [15:48:31 ] [INFO] [RequestManager] Request ID [TimesheetOperatorSuperAmend] mapped to [delegate.helper.gbms.bulkcrg.timesheet.TimesheetOperatorAmendHandler] [delegate.RequestManager.perform(RequestManager.java:77)]
    [15:48:31 ] [INFO] [RequestManager] delegate.helper.gbms.bulkcrg.timesheet.TimesheetOperatorAmendHandler Created [delegate.helper.gbms.bulkcrg.timesheet.TimesheetOperatorAmendHandler@66d4bf] [delegate.RequestManager.perform(RequestManager.java:82)]
    [15:48:31 ] [INFO] performing request delegate.helper.gbms.bulkcrg.timesheet.TimesheetOperatorAmendHandler@66d4bf [delegate.RequestManager.perform(RequestManager.java:84)]
    [15:48:31 ] [INFO] [NumberFormatException in TimesheetAddHandler:] null [delegate.helper.gbms.bulkcrg.timesheet.TimesheetOperatorAmendHandler.perform(TimesheetOperatorAmendHandler.java:96)]
    [15:48:31 ] [ERROR] java.lang.StringIndexOutOfBoundsException: String index out of range: 2
    at java.lang.String.substring(String.java:1934)
    at delegate.helper.gbms.bulkcrg.timesheet.TimesheetOperatorAmendHandler.perform(TimesheetOperatorAmendHandler.java:110)
    at delegate.RequestManager.perform(RequestManager.java:85)
    at delegate.FrontController.processRequest(FrontController.java:241)
    at delegate.FrontController.doPost(FrontController.java:378)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at sg.com.jp.framework.sso.SingleSignOnFilter.doFilter(SingleSignOnFilter.java:121)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at sg.com.jp.util.xss.XssFilter.doFilter(XssFilter.java:57)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at uiServlet.jponlinecharge.TxnLogFilter.doFilter(TxnLogFilter.java:153)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)
    [delegate.helper.gbms.bulkcrg.timesheet.TimesheetOperatorAmendHandler.perform(TimesheetOperatorAmendHandler.java:526)]
    [15:48:31 ] [INFO] errorMessage ::: There are some error with your request. Please contact administrator if problem persists. [delegate.FrontController.processRequest(FrontController.java:311)]
    =================
    Application Server Specs:
    =================
    OS: Solaris10 x86
    cat /etc/release
    Oracle Solaris 10 9/10 s10x_u9wos_14a X86
    Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    Assembled 11 August 2010
    RAM: 8GB
    HDD: 70GB
    Apps Server: WebLogic Server Version: 10.3.4.0
    Thank you and have a blessed day.
    Best regards,
    Albert

    Hi,
    Try this
    The reason for this error is that the time format entered is not correct. It should be a date and 24-hour format expressed as mm/dd/yy hh:mm:ss. For example: 07/15/10 14:30:00.
    The WebLogic Server 11g documentation gives instructions for Date/Time format. For details, please refer to
    http://download.oracle.com/docs/cd/E14571_01/apirefs.1111/e13952/pagehelp/Diagnosticsdiagnosticsviewmetricslogtabletitle.html
    Solution
    However, since you cannot open the Domain Log page again because the console hangs or reports a "Redirect Loop" error, you cannot modify this wrong time format on the console. To resolve this issue, please follow these steps:
    Stop WebLogic Server.
    Go to directory <Domain>/servers/<Server_Name>/data/console
    Either open ConsolePreferences.xml and modify the value of startrange (and/or endrange) to a correctly formatted time, e.g. 07/15/10 14:30:00
    OR
    Delete ConsolePreferences.xml entirely.
    Start Weblogic Server again.
    Regards,
    Kal

  • Java.text.DecimalFormat Error

    I have this import directive in my jsp page.
    <%@ page import="java.io.*,java.sql.*;java.text.DecimalFormat" contentType="text/html;charset=windows-1252"%>
    I am using Jdeveloper 9i 9.0.3.
    When I compile this page from within JDeveloper I get this error for java.text.DecimalFormat
    Error: 'class' or 'interface' expected
    When I compile outside JDeveloper, I get NO error.
    Can somebody tell me what the problem is.

    <%@ page import="java.io.*;java.sql.*;java.text.DecimalFormat" contentType="text/html;charset=windows-1252"%>
    I think that missing semi-colon is what's creating problems for you.
    Sergio Bastos

  • Please help! java.text.ParseException:

    Hi everybody
    why am i gatting java.text.ParseException: Unparseable date: "Jul 21, 2002"
    String s = "yyyy MM dd";
    SimpleDateFormat ff = new SimpleDateFormat(s);
    java.util.Date mm = ff.parse( DateFormat.getDateInstance().format(new java.util.Date())) ;
    System.out.println(mm.toString()); //Exception is thrown
    thanks in advence

    I didn't take time to look through your code too closely but here is some code that might help. The pullDate method reads a string from a JTextField (textField) and tries to return a Date. If it can't format it then it returns null. It tries to format the text based on the formats listed. If it can't format the text using one then it tries the next until it runs out of them. Change the formats to whatever you like. Good luck.
    Jeff
    private static DateFormatter[] altFormats = {
         new DateFormatter(new SimpleDateFormat("M/d/yy")),
         new DateFormatter(new SimpleDateFormat("MMddyy")),
         new DateFormatter(new SimpleDateFormat("MMM d, yy")),
         new DateFormatter(new SimpleDateFormat("MMM d yy")),
         new DateFormatter(new SimpleDateFormat("d MMM yy"))};
    private Date pullDate() {
         String text = textField.getText();
         Date d = null;
         int i = 0;
         while(d==null && i<altFormats.length) {
              try {
                   d = (Date)(altFormats[i++].stringToValue(text));
              } catch (ParseException e) {}                    
         return d;

  • The JAVA program for "Philosopher Problem"

    When I learn the book of "Operating Systems (Design and Implementation)"(written by Andrew S.Tanenbaum), I try to write a program for the "Philosopher Problem" . In the book there is a sample of this problem in C language, and I write it in JAVA. The following is my program, I have tested it. It is correct, but maybe it is not the most efficient way to solve the problem. Can you think out a more efficient program in JAVA to solve this problem?
    * Philosopher Eating Problem
    * @author mubin
    * @version 1.0
    public class PhilosopherEating {
    //Philosophers' number
    private final static int PHER_NUM = 20;
    //Philosophers' state
    private volatile static int[] pherState = new int[PHER_NUM];
    //THINKING
    private final static int THINKING = 0;
    //HUNGRY
    private final static int HUNGRY = 1;
    //EATING
    private final static int EATING = 2;
    //Philosophers thread group
    public static Philosopher[] philosophers = new Philosopher[PHER_NUM];
    //finish indicator
    public volatile static boolean finished =false;
    //thread lock
    public static Object threadLock = new Object();
    public PhilosopherEating() {
    * Philosopher class
    * @author mubin
    * @version 1.0
    public static class Philosopher extends Thread{
    int pherNo ;
    public Philosopher(int no){
    this.pherNo = no;
    public void run(){
    while(!PhilosopherEating.finished){
    think();
    takeForks(this.pherNo);
    eat();
    putForks(this.pherNo);
    * Thinking
    private void think(){
    System.out.println("Philosopher"+this.pherNo+"is thinking...");
    try {
    Thread.sleep( (int)(Math.random()*100));
    }catch (Exception ex) {
    ex.printStackTrace(System.out);
    * Eating
    private void eat(){
    System.out.println("Philosopher"+this.pherNo+"is eating...");
    try {
    Thread.sleep( (int)(Math.random()*100));
    }catch (Exception ex) {
    ex.printStackTrace(System.out);
    * Take the fork
    private void takeForks(int no){
    //System.out.println("takeForks:no:"+no);
    synchronized (threadLock) {
    pherState[no] = HUNGRY;
    testPher(no);
    * Put down the fork
    private void putForks(int no){
    //System.out.println("putForks:no:"+no);
    synchronized (threadLock) {
    pherState[no] = THINKING;
    if( pherState[getLeft()]==HUNGRY ){
    philosophers[getLeft()].interrupt();
    if( pherState[getRight()]==HUNGRY ){
    philosophers[getRight()].interrupt();
    * Return the NO. of philosopher who is sitting at the left side of this philosopher
    * @return the NO. of the left philosopher
    private int getLeft(){
    int ret = (pherNo-1)<0? PHER_NUM-1 : (pherNo-1);
    return ret;
    * Return the NO. of philosopher who is sitting at the right side of this philosopher
    * @return the NO. of the right philosopher
    private int getRight(){
    int ret = (pherNo+1)>=PHER_NUM ? 0 :(pherNo+1);
    return ret;
    private void testPher(int no){
    while(true){
    if(pherState[no]==HUNGRY
    &&pherState[getLeft()]!=EATING
    &&pherState[getRight()]!=EATING) {
    pherState[no] = EATING;
    //Print and check the philosophers' state
    printPher(pherState);
    return;
    }else{
    try {
    System.out.println(" Philosopher "+this.pherNo+"is waiting a fork");
    threadLock.wait();
    }catch (java.lang.InterruptedException ex) {
    System.out.println(" Philosopher "+this.pherNo+"is interrupted and woken up to take fork");
    //when it is interrupted, do nothing. Just let it continue!
    }//end of while(true)
    * Print and check the philosophers' state.
    * To insure there are no two philosophers sit side by side
    * are eating at the same time.
    private static void printPher(int[] phers){
    System.out.print(" philosophers' state��");
    for (int i = 0; i < phers.length; i++) {
    System.out.print(" "+phers);
    System.out.println("");
    for (int i = 0; i < phers.length-1; i++) {
    if (phers[i]==EATING && phers[i+1]==EATING){
    System.err.println(i+" and "+(i+1)+"two of philosophers sitted side by side are eating at the same time!");
    if (phers[0]==EATING && phers[PHER_NUM-1]==EATING){
    System.err.println("0 and "+PHER_NUM+"two of philosophers sitted side by side are eating at the same time!");
    public static void main(String[] args) {
    for (int i = 0; i < PHER_NUM; i++) {
    PhilosopherEating.pherState[i] = THINKING;
    PhilosopherEating aPhilosopherEating = new PhilosopherEating();
    for (int i = 0; i < PHER_NUM; i++) {
    philosophers[i] = new Philosopher(i);
    philosophers[i].start();
    try {
    Thread.sleep(30000);
    catch (InterruptedException ex) {
    ex.printStackTrace(System.out);
    //End all the threads of philosophers
    PhilosopherEating.finished = true;

    this problem is about learning how to use threads/synchronise objects etc, the efficiency of the code isn't really an issue, if that's what you mean. As for the efficiency of the solution, it's very hard to tell how efficient it is, but as long as all the philosphers get to eat there's no problem. I haven't really scrutized your code, but I'm not sure that you have a deadlock free solution: as long as it is possible for all the phils to pick up one fork at the same time there's a problem, and it seems from your code that each philosopher will pick up "his" fork. Again, I could be wrong, I haven't really looked. If you haven't come up with a solution, try drawing it on paper and working it out, or if you're lazy a quick google will probably give you the answer, but I'm pretty sure nobody here will :)

  • BI setup: WebAS ABAP Setting - Java to ABAP communication problem

    Hello,
    i've got a problem during intallation of BI in Netweaver 2004s. The Diagnostics & Support Desktop Tool reports errors in WebAS ABAP Settings. These errors are:
    - "Web Template Validation failed due Java to ABAP communication problem (return code:ERSBOLAP018)"  with the suggested solution "Check Connector Connection of System Object in Portal System Landscape". What does it mean?
    - "Call ABAP->Java for function RSWR_RFC_SERVICE_TEST failed for destination <destination>" and "Call ABAP->Java for function RSRD_MAP_TO_PORTAL_USERS failed for destination <destination>" with suggested solution "Check the data of the destination in transaction SM59. Check that the target host is running and has registered a program id in the gateway." Run of transaction SM59 returns no errors.
    Further i've take a look in the log 'dev_jrfc.trc' and there i found the errors:
    - Exception thrown by application running in JCo Server
    java.lang.RuntimeException: Bean RSRD_MAP_TO_PORTAL_USERS not found on host <host>
    - Exception thrown by application running in JCo Server
    java.lang.RuntimeException: Bean RSWR_RFC_SERVICE_TEST not found on host  <host>
    - Exception thrown by application running in JCo Server
    java.lang.RuntimeException: Bean RSWR_PREEXECUTION_PROXY not found on host  <host>
    Can these errors be the cause of the WebAS ABAP Setting error displayed in the Diagnostics & Support Desktop Tool? How they can be solved?
    Thanks for your help,
    Martin

    Hello Chetan,
    thanks for your response. Maybe i've described my problem not clear enough. There is no problem of installation and usage of support & dektop tool, but of installation of BI. The support & dektop tool indicates the errors described above with no other hints. My questions is, if anybody knows, what is the cause of the errors and what i must do, to install BI correctly.
    Cheers,
    Martin

  • URGENT: Entering Chinese into Java Text Area

    Hi,
    This might be an FAQ question but some of the info I've gotten over the web so far is conflicting.
    How do I allow a user to enter Chinese text into a Java Text Area (using an english keyboard)?
    All my users have:
    English Windows 2000 with a multilanguage pack. I cannot change this.
    But, I can specify any downloads (IMEs, etc.) and I can choose whichever version of Java I desire.
    Please let me know what is the simplist way to enable Chinese data entry in this environment. Let me know if I need to create my own input type :( or I can use MS Global IME) or if there are other third party chinese input types (even if they are not free).
    Thank you and have a nice day.
    Best Regards,
    Carlos

    Thanks for the note. The news was depressing - but things are much clearer now :) I would like one more clarification, though -
    On the MS site, I quote
    Any user who needs to input East Asian text across the language platforms of Windows Me, Windows 98, Windows 95, or Windows NT 4.0 could use Global IME.
    "Note: On Windows 2000, the Global IMEs work in any application since that OS has full-featured East Asian input support built in. On Windows Millennium, Windows 98, Windows 95, and Windows NT 4.0, the Global IMEs work only in supporting applications."
    When they say they say "full-featured East Asian input support built-in" does that exclude Java? If it would work, would it work with Swing or only AWT?
    Any thoughts? Thanks again for your not, I would greatly appreciate it if you could help me with this clarification.
    Best Regards,
    Carlos

Maybe you are looking for

  • Satellite P750/02Q - Should I underclock GPU?

    I've started using betas as others have said on this forum. I've found that the laptop seems to run hotter. On idle web browsing all temps are in mid 40s and can get up to mid 50s if I play a 3D video. I don't game that much. I've never received a bl

  • How to Park a doc in FB01 !

    Hi All, I have 2 options, 1 is Post a doc 2nd is PArk a doc, I am using FM => PRELIMINARY_POSTING_FB01 for Posting, but for park a doc is this FM help to me ? or anybody help me to park a doc ? IS it available  any BAPI FM or let me know any further

  • Autherntication using Open Directory and NO home folder

    We are looking to set up an Open Directory on a Snow Leopard server in our medium sized company - we would like to use it for Single Sign On authentication but do not want to create home folders on the server. All we want OD to do is authenticate We

  • DW CS3 PC to DW CS4 Mac

    I'm sure this has been done.  What's the best path for platform change and what do I ask for or tell the Adobe Customer Service folks?

  • Hiding FYI Category from Approval Region in Review Page of SSHR

    Hi, Has anyone tried to show only the Approvers list and not the FYI list in the Approvers region of the review page in Self Service HRMS. We want the FYI to be sent, so AME has been configured for that. However we don't want the FYI list to be displ