Convert String to com.stc.runtime.dt.Date

Hi every one
I need to convert a String to com.stc.runtime.dt.Date.
Can you please guide me?
thanks.

String to UtilDate:
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Calendar;
public class ttest
    private static SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMddHHmmssZ");
    private static SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
    public static void main(String[] args) {
     Date dt = null;
     try {
         dt = sdf1.parse("20040921124448+0200");
         System.out.println(dt.toString());
     catch(java.text.ParseException pe) {
         System.err.println("Incorrect Date Format!");
     Calendar cdr = Calendar.getInstance();
     cdr.setTime(dt);
     System.out.println("Year is: " + cdr.get(Calendar.YEAR));
     System.out.println("Zone Offset is: " + cdr.get(Calendar.ZONE_OFFSET));
     Date dt = new Date();
     System.out.println(sdf.format(dt));
     try {
         String sUTC = sdf2.format(dt);
         System.out.println("UTC: " + sUTC);
     catch(IllegalArgumentException pe) {
         System.err.println("Incorrect Date Format 2!");
}UtilDate and RuntimeDates
import com.stc.runtime.dt.Date;
import com.stc.runtime.dt.Time;
import com.stc.runtime.dt.DateTimeFactory;
import com.stc.otd.xsd.datatype.Date2001;
import com.stc.otd.xsd.datatype.Time2001;
import com.stc.otd.xsd.datatype.DateTime;
import java.util.Calendar;
import java.util.GregorianCalendar;
public class dates
    public static void main (String[] parameters)
     dates tq1 = new dates();
     return;
    private dates()
     java.util.Date dtUtil = new java.util.Date();
     Date2001  d2001 = utilDate2xsdDate(dtUtil);
     System.out.println("Current date is: " + d2001.toString());
     com.stc.runtime.dt.Date dt = d2001;
     Time2001 t2001 = utilDate2xsdTime(dtUtil);
     System.out.println("Current time is: " + t2001.toString());
     com.stc.runtime.dt.Time tm = t2001;
     com.stc.runtime.dt.DateTime dttm = new DateTimeFactory().createDateTime();
     //     java.sql.Timestamp dt1 = xsdDateTime2utilTimestamp(new DateTime());
     java.sql.Timestamp dt1 = xsdDateTime2utilTimestamp(dttm);
     System.out.println("Current timestamp is: " +
                  dt1.toString());
     return;
    private java.sql.Timestamp xsdDateTime2utilTimestamp(com.stc.runtime.dt.DateTime dt1)
     Calendar c = dt1.getCal();
     return new java.sql.Timestamp(c.getTime().getTime());
    private Date2001 utilDate2xsdDate(java.util.Date d1) {
     Date2001 dt = new Date2001();
     Calendar c = Calendar.getInstance();
     c.setTime(d1);
     dt.setYear(c.get(Calendar.YEAR));
     dt.setMonth(c.get(Calendar.MONTH) + 1);
     dt.setDay(c.get(Calendar.DAY_OF_MONTH));
     return dt;
    private Time2001 utilDate2xsdTime(java.util.Date d1) {
     Time2001 tm = new Time2001();
     Calendar c = Calendar.getInstance();
     c.setTime(d1);
     tm.setHours(c.get(Calendar.HOUR_OF_DAY));
     tm.setMinutes(c.get(Calendar.MINUTE));
     tm.setSeconds(c.get(Calendar.SECOND));
     return tm;
    private java.util.Date xsdDate2utilDate(Date2001 d1) {
     Calendar c = Calendar.getInstance();
     c.set(d1.getYear(), d1.getMonth() - 1, d1.getDay());
     return c.getTime();
}

Similar Messages

  • 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.

  • How to convert String (dd-MMM-yyyy) to oracle.jbo.domain.Date

    Hi
    Could you please tell how do I convert String of date in format dd-MM-yyyy to ADF date? Please show me some sample.
    Thanks

    http://javaalmanac.com/egs/java.text/FormatDateDef.html
    Once you have a java.util.Date you can convert it to oracle.jbo.domain.Date. (see http://www.fifkredit.com/bc4jdoc/rt/oracle/jbo/domain/Date.html)

  • I want convert string to date format in Oracle

    Dear All
    I want convert string to date format in Oracle,Format is given below
    'Friday, 02 March 2012 2:44 PM' to '02/03/2012 2:44 PM'

    >
    Hi Parwez,
    I want convert string to date format in Oracle,Format is given below
    'Friday, 02 March 2012 2:44 PM' to '02/03/2012 2:44 PM'SELECT TO_DATE('Friday, 02 March 2012 2:44 P.M.', 'DAY, DD MONTH YYYY HH:MI A.M.') from dual;
    As well as what the other poster suggested, look here: http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements004.htm#i34924
    HTH,
    Paul...

  • Stop download to Excel from converting string of digits & dashes into date

    Hi,
    How can I stop BI and Excel data from converting a column of string data that is comprised of numbers and dashes into a date format when it is downloaded into Excel?
    I'd like to solve this problem in BI, so that any users can download the data from a BI report into Excel without having to change the Excel date column back into a string column.
    Thanks,
    Darcy

    Hi Again Darcy,
    hmmm... That is very interesting. I just tried on OBIEE 10.1.3.2 ( a version before yours) on Windows XP with Office 2003 and an Oracle 11g DB backend and it did not have any problems pulling the value as text and not a DATE
    Can you try something for me? In a new report, add any old dimensional (year, month name, etc) field twice into the report and change the second column formula to be following: '7001-2'
    Try to export that report and see if that value comes through as text or a date. If it is something about the SQL server data set, then the above test should come through as text object in your excel download because we aren't pulling it from SQL Server, we'll creating it directly in OBIEE. If the above test does come through as a date, then it should mean that SQL Server isn't the issue. And if that is the case, I am starting to wonder if there's a setting in Office to can be enabled/disabled to avoid any data casting.
    Best regards,
    -Joe

  • Convert String to java UTC date then to sql date

    Hi,
    I am trying to convert string (MM/dd/yyyy format) to UTC date time and store in the database.
    This is what I did:
    String dateAsString = "10/01/2007";
    SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
    formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
    formatter.setLenient(false);
    java.util.date dateValue = formatter.parse(dateAsString, new ParsePosition(0));
    dateValue will be Sun Sep 30 20:00:00 EDT 2007 in UTC.
    Now I need to store this date and time to MS SQL database.
    I used the following code:
    java.sql.Date sqlDateValue = new java.sql.Date(parsedToDate.getTime());
    But this code give only the date, not time 2007-09-30
    Can anybody tell me how I can change this java date to sql date (or datetime?) so that I can get both date and time.
    Thanks,
    semaj

    semaj07 wrote:
    Hi,
    I am trying to convert string (MM/dd/yyyy format) to UTC date time and store in the database.
    This is what I did:
    String dateAsString = "10/01/2007";
    SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
    formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
    formatter.setLenient(false);
    java.util.date dateValue = formatter.parse(dateAsString, new ParsePosition(0));
    dateValue will be Sun Sep 30 20:00:00 EDT 2007 in UTC.
    Now I need to store this date and time to MS SQL database.
    I used the following code:
    java.sql.Date sqlDateValue = new java.sql.Date(parsedToDate.getTime());
    But this code give only the date, not time 2007-09-30
    Can anybody tell me how I can change this java date to sql date (or datetime?) so that I can get both date and time.
    Thanks,
    semajTake a look at java.sql.Timestamp:
    http://java.sun.com/javase/6/docs/api/java/sql/Timestamp.html
    Edited by: hungyee98 on Oct 17, 2007 8:57 AM

  • Converting String Date to Date Format

    Hope you can help, I am tearing my hair out. I have a 2D table that stores information. I have a field that records a date in the format 03-May-11 (this is a string). However, it is also stored as a number 40666 in a sortkey field. The string field is CLIENT2D.INFO1 and i have tried to use Date({CLIENT2D.INFO1}) to show as a date, which it does, until i want to use it as a parameter i.e. bring records between two dates. It errors and comes up with bad date format.
    Is the 40666 number Unix Time? If so is there anyway to convert this to a Date 03/05/11?

    Try
    CDate({CLIENT2D.INFO1})
    Ian

  • Not able to convert string attribute to number and date please help me out

    not able to convert string attribute to number and date attribute. While using string to date conversion it shows result as failure.As I am reading from a text file. please help me out

    Hi,
    You need to provide an example value that's failing and the date formats in the reference data you're using. It's more than likely you don't have the correct format in your ref data.
    regards,
    Nick

  • Facing problem in converting string to date using getOANLSServices()

    I am trying to set a value for date field in my vo and trying to insert into the table.
    In controller I am getting the String which has a date:
    ex: String date="01-NOV-2007";
    while setting into the row I need to convert into Date but it is returning null.
    The below code I used
    to convert into date :
    Date dt = new Date(getOADBTransaction().getOANLSServices().stringToDate(date));
    But this dt is returning a null value is there any solution please advise me.
    Regards!
    Smarajeet

    Smarajeet ,
    See this thread, in one of my replies i have mentioned how to convert string to java.sql.date.You can use the same for oracle.jbo.domain.Date.
    urgent!How to set the default selected date for an OAMessageDateFieldBean
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Convert string to date

    I'm trying to convert a string "2004-08-12" to a date of format "mm/dd/yyyy" like 08/12/2004.
    how do I do this?
    thanks.

    SimpleDateFormat sdfInput = 
           new SimpleDateFormat( "yyyy-MM-dd" ); 
        SimpleDateFormat sdfOutput = 
           new SimpleDateFormat ( "MM/dd/yyyy" ); 
        String textDate = "2001-01-04"; 
        Date date = sdfInput.parse( textDate ); 
        System.out.println( sdfOutput.format( date ) );

  • Converting string into date

    How can I convert a string 07-27-2001 in a date.

    How can I convert a string 07-27-2001 in a date.
    one of the solutions might be --
    SimpleDateFormat format = new SimpleDateFormat ("MM-dd-yyyy");
    Date date = format.parse("07-27-2001");

  • Needed help regarding converting  string to java.sql.Date format

    I have a a function which returns a calendar object. The date must be inserted to Oracle DB using java.sql.Date format.
    So i have converted the Calendar object to java.sql.Date format using the following code
    java.sql.Date publicationDate = new java.sql.Date(book.getPublicationDate().getTime().getTime());But while getting inserted into the DB it was in mm/dd/yyyy format whereas i wanted dd/mm/yyyy format
    Can any body please help out how to store the date in dd/mm/yyyy format ?

    Can u please explain this a bit
    This is my code
    public int addBook(List<Book> BookList) throws SQLException, ParseException{
              System.out.println("Hi there");
              Book book = new Book();
              BookDB bookDb = new BookDB();
              //listLength =      BookList.length;
              String bookId = null;
                   try{
                        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                        con  = DriverManager.getConnection("jdbc:oracle:thin:@10.123.79.195:1521:findb01","e115314", "e115314");
                        addBook = con.prepareStatement("insert into ABC_Book values(?,?,?,?,?,?,?)");
                        Iterator<Book> iterator = BookList.iterator();
                        while(iterator.hasNext()){
                             book = (Book)iterator.next();
                             System.out.println(book.getBookId());
                             addBook.setString(1,book.getBookId());
                             addBook.setString(2,book.getTitle());
                             addBook.setString(3,book.getAuthor());
                             addBook.setString(4,book.getPublisher());
                             System.out.println(book.getPublicationDate());
                             System.out.println("Before Date");
                             System.out.println("book.getPublicationDate().getTime()"+book.getPublicationDate().getTime());
                             java.sql.Date publicationDate = new java.sql.Date(book.getPublicationDate().getTime().getTime());
                             SimpleDateFormat formatter = new SimpleDateFormat("dd/mm/yyyy");
                             dateString = formatter.format(publicationDate);
                             System.out.println("Today is"+dateString);
                             java.sql.Date date = (java.sql.Date)formatter.parse(dateString);
                             System.out.println("date"+date);
                             //java.sql.Date publicationDate = (Date)book.getPublicationDate().getTime();
                             //System.out.println("Value of date is"+publicationDate);
                             System.out.println("After Date");
                             addBook.setDate(5,publicationDate);
                             addBook.setString(6,book.getCountry());
                             addBook.setString(7,book.getLanguage());
                             rs = addBook.executeQuery();
                             //con.commit();
                             rowCount = rowCount + rs.getRow();
                        return rowCount;
                   catch(SQLException se){
                        se.printStackTrace();
                   finally{
                        con.close();
                        System.out.println("After adding ");
              return 0;
         }

  • Converting String to Date (java.sql.date)

    Hi,
    Kindly let me know how I can convert a string like
    "20061102" (YYYYMMDD) to a Date type (java.sql.date) in web Dynpro.
    Requirement is to set a DateType context Attribute with
    the value contained in the String ("20061102" ).
    Awaiting your kind responses..
    Regards,
    Mahesh

    SimpleDateFormat yyyyMMdd_parser = new SimpleDateFormat(
                   "yyyyMMdd");
    java.util.Date date=yyyyMMdd_parser.parse("20061102");
    java.sql.Date slqDate=new java.sql.Date(date.getTime());

  • Output csv comes as "Microsoft.Exchange.Data.MultiValuedProperty`1[System.String]" why?

    [PS] C:\temp01\finalScript>Get-CASMailbox JLEE -ResultSize "Unlimited" | Select samAccountName,displayname,ActiveSyncBlo
    ckedDeviceIDs,ActiveSyncAllowedDeviceIDs
    when I reun the above in Shell I get
    SamAccountName                DisplayName     ActiveSyncBlockedDeviceIDs    ActiveSyncAllowedDeviceIDs
    JLEE                          Lee, Jeong S                 
    {}                                          {ApplF78L4ATSFFHG}
    When I export to CSV I get
    "SamAccountName","DisplayName","ActiveSyncBlockedDeviceIDs",    "ActiveSyncAllowedDeviceIDs"
    "JLEE",  "Lee, Jeong S","Microsoft.Exchange.Data.MultiValuedProperty`1[System.String]","Microsoft.Exchange.Data.MultiValuedProperty`1[System.String]"
    display on screen ActiveSyncAllowedDeviceIDs comes as {ApplF78L4ATSFFHG}W
    Output csv comes as "Microsoft.Exchange.Data.MultiValuedProperty`1[System.String]"  why?
    When I export to CSV I want to come as ApplF78L4ATSFFHG}

    its an array of values so you have to expand it try:
    Get-CASMailbox JLEE -ResultSize
    "Unlimited" | Select samAccountName,displayname,@{Expression={$_.ActiveSyncBlockedDeviceIDs};Label="BlockedDevices";},@{Expression={$_.ActiveSyncAllowedDeviceIDs};Label="AllowedDevices";}

  • Problem in  Converting String to Date

    Hi All,
    I am having one String
    String date = "2006-01-17 15:19:57.0"
    I want to parse this String into Date object.
    I will really appriciate if somebody helps me out.
    Thanks.

    You're specifying a 'T' and a timezone in your format, but they're not present in the string you're parsing.
    I'm assuming from the way you're printing out the date, that your thinking is along these lines: "sdfInput will parse the input string, no matter what format it's in, and will produce a Date object. That Date object wil have the format specified in sdfInput."
    This is wrong on a couple of fronts:
    1) DateFormat doesn't magically figure out what format it's supposed to use for the String it's parse()ing. The String has to match the DF's format.
    2) Dates don't have formats. Only Strings do. A Date object is just a long. There's no relationship whatsoever between the Date that you get from parse() and the format that was used to produce it. When you print out a Date as you're doing, its toString method is called, which in turn uses a default format for your Locale.
    If you want to turn a date string in one format into a date string in another format, use two different DateFormat objects with two different formats. Date date = df1.parse(inputString);
    String outputString = df2.format(date);

Maybe you are looking for