Convertion string to Calender object

The input string format is "hh-mm-ss". How can I convert to Calender object.
Can anybody suggest ?
Thanks
Pravat

Use a java.text.SimpleDateFormat to convert the string to a java.util.Date object and then set the calendar object from that.

Similar Messages

  • Converting String to an Object of a class

    Hi all,
    I want to convert a string to an object of a class.
    Please see my below code:
    MyClass rahul = null;
    String data = "DATA";
    rahul = (MyClass) data;
    I am getting the error: Invalid cast from java.lang.String to MyClass
    Please help me as its urgent

    There is no magical String deserialization in java. If your class can convert it's state to a string, then you will need to write the reverse parsing code, presumably using either a constructor which takes a string, or a static method similar to how numbers are handled, like:
    MyClass c = MyClass.valueOf(data);Obviously, in either case you will need to write the code to do this.

  • Converting String to Calendar Object

    Hi,
    I nedd to Change the below String to Calendar Object.i want to show the records which are older than half an hour.any other idea which will solve my problems?
    Fri Aug 17 01:56:40 GMT+05:30 1906
    Thanks in advance.
    Regards:
    Akash.

    Look at
    java.text.SimpleDataFormat

  • Converting Strings to Color Objects

    Greetings All -
    I'm in my first Java class (I was a C programmer in the 80s!) and am a little stumped on an assigment. Your help will be much appreciated.
    I have to read color strings out of an HTML file and put them in a HashMap (a small applet assignment). I've been unable to find an elegant method for converting from a string to a color object.
    Please let me know if I'm stuck with a big nested if or am I overlooking something?
    Thank you -
    Gargoyle

    This will handle #rrggbb strings, and also the dozen or so colors defined by name (red, cyan, etc) in the static fields of java.awt.Color:
    static Color stringToColor (String s)
         try {
              return Color.decode(s);
         } catch (Exception e) {}
         try {
              return (Color) Color.class.getField(s).get(null);
         } catch (Exception e) {}
         System.out.println("bad color string: " + s);
         return null;
    }

  • Issue with converting string to date object

    Hi all,
    I have a problem with sorting a list of dates in a table column. My dates are in the format 'yyyy-Mmm-dd'(Eg: 2009-Dec-23). Can someone help me how to sort the dates in this format. here is the code which i tried.
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-Mmm-dd");
              Date d1= new Date();
              Date d2= new Date();
              try {
                   d1 = dateFormat.parse("2006-Jun-09");
                 d2 = dateFormat.parse("2006-Apr-10");
              } catch (ParseException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              System.out.println("converted date 1"+ d1);
             System.out.println("converted date 1"+ d2);
    Exception : Unparseable date: "2006-Jun-09"
         }Please someone help me how to pass this date in the right format.

    I believe twisai may have lost the documentation so he/she can figure this out rather than guess that "Mmm" means 3-letter month, first letter capitalized. Let me remind him of the link:
    [http://java.sun.com/javase/6/docs/api/index.html]

  • String to xml object java

    Hello,
    can anyone suggest me how to convert string to xml object in java?
    I have a string (Data) ant now I have to pass it as parameter as xml object, which structure should be:
    <MGWData>Data</MGWData>
    Where I surf I always see only solutions for converting string to xml document, but never to xml object.
    maybe the problem is I don't completely understand what xml object is in first place :/
    Any answer would help.
    Thanks.

    894871 wrote:
    here is the method to call:
    +/**+
    * Sets the p_DATAXMLTYPEIN value for this SVARCHAR2INSERT_RECEIVESInput.
    *+
    * @param p_DATAXMLTYPEIN
    *public void setP_DATAXMLTYPEIN(com.oracle.xmlns.orawsv.SISTEMA_MOKA.MGW_PUBLIC_FUNCTIONS.SVARCHAR2INSERT_RECEIVESInputP_DATAXMLTYPEIN p_DATAXMLTYPEIN) {*
    this.p_DATAXMLTYPEIN = p_DATAXMLTYPEIN;
    one of the classes contains:
    *public class SVARCHAR2INSERT_RECEIVESInputP_DATAXMLTYPEIN  implements java.io.Serializable, org.apache.axis.encoding.AnyContentType {*
    *private org.apache.axis.message.MessageElement [] _any;*
    this method and some classes where generated using eclipse and wsdl file by creating web service client.
    wsdl says for that part: *<xsd:element name="P_DATA-XMLTYPE-IN">*
    So I suppose it should involve smth org.apache.axis.message.MessageElement. But when I create any type of parameter, it gives me error:
    + ....cannot be cast to com.oracle.xmlns.orawsv.SISTEMA_MOKA.MGW_PUBLIC_FUNCTIONS.SVARCHAR2INSERT_RECEIVESInputP_DATAXMLTYPEIN+
    I am new in web service stuff so thank you for response.Can you explain in plain English what you are trying to do? Or provide a [url http://sscce.org/]SSCE.

  • How can I convert a string to an object or class

    I would like to read a file representing a class, and convert it to an object or a class (object preferred). Other postings suggest using javax.tools.JavaCompiler to convert from a string but then say that this is not always available (posting on 1 Jan 09). If this is still not universally available is there another way to do this? If this is not available, are there any examples of how it should be done?
    My understanding from what I've read is to read the file into a String then compile the String using javax.tools.JavaCompiler, which is an Interface.
    thanks

    skidmarks wrote:
    What i would like to do is to take a Java file representing a class and compile it at runtime. However, the comment about a JDK being available at runtime makes this unattractive.So, you want to compile .java files, but you don't want to have to use a compiler?
    The next guess would to be to create a .jar file and reference it at runtime. Here's the scenario:Eh? How is that even remotely equivalent?
    1. People using the 'system' will have a varied knowledge of Java.
    2. My hope was to require that anyone using the program would only need to create a Java Class file,You mean a Java source file. You have said that YOU want to create the .class file. If they are creating the .class file, then all you need to do is load it with a ClassLoader and start using it.
    You might try clarifying your requirements a bit.
    In either case, the Class Files would look like:
    public class Name {
    int field1;
    float field2;
    } With all the field types being simple Java Primitives.What is the point of this? What are you ultimately trying to accomplish, that can be served by user-defined groups of primitives, with no complex object graphs and no user-defined methods?
    Depending on what you're really getting at, using scripting features via beanshell, groovy, or javascript might be an approach to consider, or using Scala to produce a domain-specific language (although I suspect that last may be overkill, and beyond your current skill level).
    If this is so, is there any way to create a .jar file at runtime? Do I have to exec("jar") or is there another way.A .jar file is just a .zip file with a manifest. Look at the java.util.jar package. But note that creating a .jar file has nothing to do with the rest of what you're asking about.

  • Convert String variable value  to an Object referece type

    Hi all,
    I want to know that if there any possible way to convert String variable value to a Object reference type in java. I'll explain by example if this is not clear.
    Let's think that there is a string variable name like,
    String name="HelloWorld";
    and there is a class name same to the variable value.
    class HelloWorld
    I am passing this string variable value to a method which is going to make a object of helloworld;
    new convertobj().convert("HelloWorld");
    class convertobj{
    public void convert(String name){
    // in hert it is going to create the object of HelloWorld;
    // HelloWorld hello=new HelloWorld(); just like this.
    now i want to do this from the name variable value.( name na=new name()) like wise.
    please let me know if there any possible way to do that.
    I am just passing the name of class by string variable then i wanted to make a instance of the class which come through the variable value.
    thanx.

    Either cast the object to a HelloWorld or use the reflection API (Google it) - with the reflection API you can discover what methods are available.
    Note: if you are planning to pass in various string arguments and instantiate a class which you expect to have a certain method... you should define an interface and have all of your classes that you will call in this way implement the interface (that way you're sure the class has a method of that name). You can then just cast the object to the interface type and call the method.
    John

  • How to convert a string to date object?

    I have a string user input for date.
    I want to convert it to Date object to insert it in database.
    How to do it?

    Check the java.text.SimpleDateFormat class. You can use it for parsing dates. API contains good description how to build the format pattern.
    HTH
    Mike

  • Converting a String to an Object

    Is there some way of converting a String (from a textfield) to an Object? What I want is something similar to the functionality offerred by a JTable. This is because I want the user to be able to input a value of any type to the textfield (e.g. String, int, boolean, etc) and get its object representation ...
    Would a simple cast do ?
    David

    dattard,
    A string is an object, when someone enters something into a JTextField, REGARDLESS of what it is (int, double, string, etc) it is stored in the string text in that text field (JTextField.getText()).
    So if someone enters in "123", its the STRING 123, not the number one hundred and twenty three... to GET the number 123, you'll need to do something like:
    int value = Integer.parseInt( myTextField.getText() );
    to have the string parsed for the value, if you want a double, same idea:
    double value = Double.parseDouble( myTextField.getText() );
    NOTE: The number wrapper classes (Integer, Double, Float, etc.) contain "parseXXXX" methods that allow you to parse a corresponding numeric value out of a String object.
    Also, when a user enters ANYTHING into a text input field of any type, its ALWAYS a String, if you want a different version of what they entered, its up to you to parse it and decide what it was.

  • Convert strings to publicKey/privateKey objects

    Hi,
    I have the following problem : I'm generating RSA key pairs in string formats. I want to sign an XML document so I have to specifiy KeyPair object in order to do that.
    How can I convert string to publicKey and privateKey objects ?
    i.e How can I correct this code :
    String pubKey = generatePublicKey();
    String priKey = generatePrivateKey();
    KeyPair kp = new KeyPair(pubKey,priKey);
    // sign the XML documents
    Thanks a lot for your precious help.
    Cheers,
    Othman.

    http://forum.java.sun.com/thread.jspa?threadID=577716&tstart=0

  • Convert String to Date and Format the Date Expression in SSRS

    Hi,
    I have a parameter used to select a month and year  string that looks like:    jun-2013
    I can convert it to a date, but what I want to do is,  when a user selects a particular month-year  (let's say "jun-2013")
    I  populate one text box with the date the user selected , and (the challenge Im having is)  I want to populate a text box next to the first text box with the month-year  2 months ahead.    So if the user selects 
    jun-2013   textbox A will show  jun-2013 
    and textbox B will show  aug-2013..
    I have tried:
    =Format(Format(CDate(Parameters!month.Value  ),  
    "MM-YYYY"  )+ 2  )   -- But this gives an error
    This returns the month in number format   like "8"    for august...
    =Format(Format(CDate(Parameters!month.Value  ), 
    "MM"  )+ 2  )
    What is the proper syntax to give me the result    in this format =  "aug-2013"  ???
    Thanks in advance.
    MC
    M Collier

    You can convert a string that represents a date to a date object using the util.scand JavaScript method, and then format a date object to a string representation using the util.printd method. For more information, see:
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1254.html
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1251.html
    In your case, the code would be something like:
    var sDate = "2013-01-10";
    // Convert string to date
    var oDate = util.scand("yyyy-mm-dd", sDate);
    // Convert date to new string
    var sDate2 = util.printd("mm/dd/yyyy", oDate);
    // Set a field value
    getField("date2").value = sDate2;
    The exact code you'd use depends on where you place the script and where you're getting the original date string, but this should get you started.

  • Conversion of string into XML object

    Hi
    I am having some problems with conversion of string (containing XML data) into Flex XML object and binding it later to UI elements to output/maintain this data.
    Binding of XML structure to UI elements works perfectly fine if I will do following:
    1)      Hardcode XML object within Flex file
    2)      Read xml file from repository (xml file inside the Flex project)
    3)      Use HTTP request to retrieve XML data
    Unfortunately none of the above scenarios suits my solution.
    I am developing a prototype application for processing Flex forms inside SAP system. I have decided to make data bindings using XML structure stored in Data Base. When rendering form inside web browser based application I am retrieving corresponding XML schema (empty for new forms and populated for saved forms) and pass it to Flex form as a string type import parameter. Data is being passed correctly (I can display it on TextArea control for instance) but after conversion to XML and binding to DataGrid I am not getting any results.
    I am converting string (containing XML) to XML object in following way:
    Private var xml_obj:XML = new XML(string_xml );
    I am catching any potential errors but conversion is going well. After conversion I am not getting any results after binding it to DataGrid control and I am not able to access any of the nodes using AS code either. At the same time variable xml_obj is not empty (not null).
    Any help would be much appreciated.
    Regards
    Michael

    David
    First of all sorry for not stating it clearly but I am using Flex 3 for this development (at the moment it is the only choice when embedding Flex objects inside SAP applications).
    You must have missed the bit where I am describing how this XML data finds its way inside Flex. I am passing it to Flex as String type parameter during rendering (directly from DB where it is stored).
    Now, following code works perfect (XML is embedded inside Flex project):
                    <mx:XML id="form_data" source="../assets/example_xml_data.xml"/>
                    <mx:Script>
                                    <![CDATA[
                                                    import mx.collections.XMLListCollection;
                                                    import mx.controls.Alert;
                                                    [Bindable]
                                                    public var XML_list:XMLListCollection;
                                                    private function setParameters():void
                                                                   XML_list = new XMLListCollection(form_data.*);             
                                    ]]>
                    </mx:Script>
                    <mx:DataGrid id="myDataGrid" dataProvider="{XML_list}">
                                    <mx:columns>
                                                    <mx:DataGridColumn dataField="COMMON" headerText="Popular name"/>
                                                    <mx:DataGridColumn dataField="BOTANICAL" headerText="Botanical name"/>
                                                    <mx:DataGridColumn dataField="ZONE" headerText="Zone"/>
                                                    <mx:DataGridColumn dataField="LIGHT" headerText="Light"/>                                                                                                                                               
                                                    <mx:DataGridColumn dataField="PRICE" headerText="Price"/>                                               
                                                    <mx:DataGridColumn dataField="AVAILABILITY" headerText="Availability"/>                                    
                                    </mx:columns>               
                    </mx:DataGrid>
    But following code does not work (XML passed to Flex form as String input parameter):
    import sap.FlashIsland;
    import mx.controls.Alert;
    import mx.collections.XMLListCollection;
    [Bindable]
    public var xml_data:String;
    private var form_data:XML;
    [Bindable]
    private var XML_list:XMLListCollection;
    private function initApp():void
                    FlashIsland.register(this);
    private function setParameters():void
                    try
                                    form_data=new XML(xml_data);
                    catch (error:Error)
                                    Alert.show(error.toString());
                      XML_list = new XMLListCollection(form_data.*);           
    XML string does find its way inside Flex form. I can display content of variable xml_data in TextArea and all looks fine. Conversion to XML (variable form_data) goes well (no error)
    Please helpJ
    Regards
    Michael

  • Converting strings to the floating number and plotting

    Hello,
    I have a question regardting converting string of numbers to the floating bumbers and plot for voltage vs. weight.
    The load cell for the ADC resolution is 16 bits, and the voltage will be in between +-5 volts.
    The problem, I have the most is converting the string of numbers to the floating numbers, in my case is the weight.
    Attachments:
    tunnelv1.vi ‏139 KB

    When you say "string of numbers" do you mean an array? What is the specific issue you are having? You seem to have orange wires running all over the place. Give a small example demonstrating the problem.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Converting String to ISO-8859-1 html charset

    i want to convert string to ISO-8859-1 html charset or vice versa
    For example i need to replace "ö" as  "&#246;"
    How can i do that?
    http://www.unicodetools.com/unicode/utf8-to-latin-converter.php

    i want to convert string to ISO-8859-1 html charset or vice versa
    For example i need to replace "ö" as  "&#246;"
    How can i do that?
    http://www.unicodetools.com/unicode/utf8-to-latin-converter.php
    This seems to return #246; but not &#246; for ö. Unless the & character is not getting displayed for some reason.
    HttpUtility.HtmlEncode Method (String)
    HttpUtility.HtmlDecode Method (String, TextWriter)
    Option Strict On
    Imports System.Web
    Imports System.IO
    Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.Text = "Form1"
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim myString As String = "ö"
    Dim myEncodedString As String = HttpUtility.HtmlEncode(myString)
    Label1.Text = " " & myEncodedString & " "
    Dim myWriter As New StringWriter()
    HttpUtility.HtmlDecode(myEncodedString, myWriter)
    Label1.Text &= myWriter.ToString
    End Sub
    End Class
    La vida loca

Maybe you are looking for

  • The VCC property was not found on the resource

    Hi all, I used a subversion to download/upload process in one of my application. At a point it give an error like this. svn: The VCC property was not found on the resourceCan someone tell me what that error means, and how to fix it. Thanks in advance

  • Grid pattern around desktop icons and pointer?

    I'm starting to get a square pattern of short lines, about an inch square, around all the icons on the desktop, in the dock, and the arrow pointer. Windows all appear OK, as is the background where there are no icons or folders, so it seems to be an

  • Sales order net value

    How and where the sales order net value will be communicate with credit management as a open order value?

  • Error in sys_panama.og un Sun Solaris

    Error is no such class type PGRP see part of dump: Any ideas? Thanx, Bas. (JspApplication.java) at oracle.jsp.JspServlet.doDispatch(JspServlet.j ava) at oracle.jsp.JspServlet.internalService(Compile d Code) at oracle.jsp.JspServlet.service(JspServlet

  • Cant sync windows live contacts on macbook

    hi, i wanna sync my windows live account for saving contacts and calendars on my macbook pro i somehow managed to connect mail application with windows live , on calendars i have registered it but it is not working , in calendars i cant see windows o