Date (the Date type) + time (String type) == Calendar type

I need to convert a date date containing a pair of Date and Time to Calendar. The date is from the Date type and the time is from a String such as "10:30 AM". This pair of data is entered on UI by a user. And I use DateFormat to make the conversion. It seems to me that I have to use deprecated Date methods such as getYear(), getHour().
Any better approaches?

Well, the java.util.Date class represent a specific "point" in time, with second precision. So, once you have your semantically right Date instance, it's just a matter of creating a new Calendar, and calling setTime.
Or maybe you should just create a Calendar instance from the start, since that's what the user is entering.

Similar Messages

  • Why are date and time strings lost when indexing an array in a for loop

    Hi, 
    I have an application where i'm reformatting data from a spreadsheet for graphical display on a LabVIEW dashboard.
    the original spreadsheet has date and time values in separate columns, and i'm merging them and converting to a timestamp value.  But something's not working.  Does anyone know why the string value is lost when the array indexes into this for loop?
    Attachments:
    failed array index.png ‏142 KB

    Can you attach your VI with some typical values? (e.g. create in indicator on the 2D array, run your VI, then turn the indicator (now containing data) into a diagram constant). Place the FOR loop related code and that diagram constant into a new VI and attach it here.
    How many times does the FOR loop run? Could it be that the last element of each 1D array is an empty string? (unless you put a wait inside the FOR loop, you'll never see the other elements in the probe)
    LabVIEW Champion . Do more with less code and in less time .

  • How can I change the snooze alert time for my calendar?

    I have no idea what the default snooze time is as I have never seen where this is an option. It is annoying to get five snooze alerts for five different events with no way to modify when I want them. Is anyone looking at this?

    No. You can't change it.

  • How do you turn off the displayed start time in individual calendar events? (Mavericks)

    In iCal there was a preference option. It would seem that has gone away in Mavericks Calendar. Any work-arounds?

    You could make them all day events, which will display as a banner.

  • The CFINPUT TYPE=DATEFIELD does not want to accept the date from the database

    I got a weird problem which I guess can be just a way to
    explain to the server how to interpret the value. I am using
    ColdFusion 8 with SQL 2005 Express. In my table, the field is a
    DATETIME field and shows the date with time (eg. 2007-07-23
    00:00:00).
    In my form, when I am adding using the DATEFIELD as the type
    for CFINPUT, it records the date correctly. But when I use the
    EDIT.cfm form and try to put the value from the database into the
    DATEFIELD CFINPUT, the server generate an error. Here is the error:
    2007-07-23 00:00:00/0 is an invalid date or time string.
    Of course, I tried many things but mostly I tried to force
    the format of the date with DATEFORMAT(qGetNewsInfos.dtIssued,
    'mm/dd/yyyy') and many more format but without success.
    Is anybody know the trick how to use a date into a
    <CFINPUT TYPE=DATEFIELD>?

    I tried the method like this and still got the same problem:
    <cfinput type="datefield" value="#DateFormat(now(),
    'mm/dd/yyyy')#">
    The system return this error:
    08/13/2007 is an invalid date or time string.
    I can use this method to record the date of parution of the
    News but cannot use it to put a vlue in the CFINPUT? This is not
    making any senses!

  • Put the current date and time in a string

    I am having trouble trying to put the current date and time from my Calendar object into a string
    any ideas?

    Calendar timeCal = Calendar.getInstance();
    timeCal.setTime(new Date(System.currentTimeMillis() - startTime ));
    String date = formatToTwoDigits(timeCal.get(Calendar.HOUR_OF_DAY))     + ":" +
    formatToTwoDigits(timeCal.get(Calendar.MINUTE))          + ":" +
    formatToTwoDigits(timeCal.get(Calendar.SECOND));
    private String formatToTwoDigits(int i) {
    String ret = null;
    i = i % 100;
    if (i < 10) {
    ret = "0" + Integer.toString(i);
    } else {
    ret = Integer.toString(i);
    return ret;
    You can figure out yourselve how to display the date, use other Calendar.XXX properties.
    Good luck!

  • Help with Date n time!!

    I am having problems with time and dates.
    I am reading records from the database which is in time format (hh:mm) but when I am reading those records it is giving me this; like:
    <b>10:00 AM in the database would be something like this</b>
    <b>12/31/1899 10:00 AM some junk.</b>
    How would u convert time in the same format I have in the database.
    How would u add time.Please help!!
    My project is at halt b/c of this..

    I am assuming that you have read the link that I've posted but don't understand what it said....So, here is a code snipet that shows you how you can convert the time string and the date-and-time string:
    try {
       SimpleDateFormat df=new SimpleDateFormat("hh:mm a",Locale.getDefault());
       Date date=df.parse("10:00 AM");
       System.out.println(date.getTime());
       df=new SimpleDateFormat("MM/dd/yyyy hh:mm a z",Locale.getDefault());
       date=df.parse("12/31/1999 10:00 AM CST");
       System.out.println(date.getTime());
    } catch (Throwable e) {}Note that date.getTime() returns a long integer representing number of milliseconds (in the case where a date is involved, the number starts at 0 for 1/1/1970 -- a negative number is for a date prior to 1/1/1970). To find seconds, divide date.getTime() by 1000, to find minute, divide by 60000, etc....)
    To answer your other problem, you can subtract one date.getTime() value by another. Unfortunately Java developers didn't see fit to provide classes to do date arithmetic.
    Hope this answer your questions.
    V.V.

  • How to compare the current system time with two timing?

    want to get the current system time and compare with the two different timing example startwindow time as 2:00:00AM and endWindowTime as 6:00:00AM. if my current system time falls between these window i have to execute my rest of the code.
    my below code works for fine for JAVA 1.6 version when i do the same code with JAVA 1.4 i am getting different date and time
    String starTime=(String) NightlyvendorStatus[0].getPropertyValue("startTime");
      String endTime=(String) NightlyvendorStatus[0].getPropertyValue("endTime");
      Date windowStarttime = new SimpleDateFormat("HH:mm:ss").parse(starTime);
      Date windowEndtime = new SimpleDateFormat("HH:mm:ss").parse(endTime);
      Date systemdate = new Date();
      SimpleDateFormat parser = new SimpleDateFormat("HH:mm:ss");
      String systemTime=parser.format(systemdate);
      Date currentTime = new SimpleDateFormat("HH:mm:ss").parse(systemTime);
      if (currentTime.after(windowStarttime) && currentTime.before(windowEndtime)){
    --- rest logic here---}
    the output from JAVA 1.4 IS Thu Jan 01 02:00:00 GMT 1970 Thu Jan 01 06:00:00 GMT 1970 Thu Jan 01 03:23:00 GMT 1970
    HOW TO DO this logic..

    Hi,
    You can try converting dates into timestamp and compare just like as comparing two integers variables.
    Regards,
    Anshul

  • How do I switch Travel Time in Mac Calendar from work to home?

    I recently installed Mavericks and have been using the new Travel Time feature in Calendar.  Today I ran into a problem, however.  I scheduled an appointment and put in the location address.  When I went to enter the travel time, it only gave me two options:  walking from work and driving from work.  There was no option for driving or walking from home.  This has never been a problem before.  What's going on here?

    From Calendar Help:
    Choose to see travel time from your starting location to the event’s location.
    To set your starting location, Calendar first looks for your location in any events that are up to three hours before this event. If Calendar doesn’t find a location, it uses your work address during work hours and your home address during other hours. (Your work hours are set in Calendar preferences using the “Day starts at” and “Day ends at” menus.) If your card in Contacts doesn’t have your addresses, Calendar uses your computer’s current location.
    Also:
    https://discussions.apple.com/message/23549295#23549295
    https://discussions.apple.com/message/23521087#23521087

  • How to format this string 7414;#Butler, Heather at the same time handling the data type

    I need to insert a nvarchar type column with data like 7414;#Butler, Heather   into a int type column, but only with the number before the before the character ; in the mentioned string.
    In the above case only 7414 needs to be inserted into the in type column of another table. This integer value need not be restricted to 4 characters. It may be 3 or 5 characters too or anything.
    Any help is appreciated....

    Extension of Li's sql
    Try this
    declare @s varchar(50)
    set @s='74146;#Butler, Heather'
    --set @s='74;#Butler, Heather'
    Select cast(cast(substring(@s, 0, charindex(';',@s)) as CHAR(4)) as int)
    --Prashanth

  • DATE type returned from function does not return the time component

    Hi,
    I'm dealing with a strange problem. I have a PL/SQL function (running on Oracle 8.1.4.7) which returns a DATE value. Like we all know the DATE datatype includes a date component and a time component.
    The function I used for testing is like this:
    FUNCTION ReturnDate return Date is
    dReturn Date;
    Begin
    select sysdate into dReturn from dual;
    return dReturn;
    end ReturnDate;
    When I call this function from .NET using ODP.NET the date value I get does not have the time component included only the day-month-year components.
    This is a code-snippet that calls the function :
    command.CommandText="Schema.ReturnDate";
    command.CommandType=CommandType.StoredProcedure;
    command.Parameters.Add("Return_Value",
    OracleDbType.Date,0,ParameterDirection.ReturnValue);
    command.ExecuteNonQuery();
    I use the OracleDbType.Date type which I think is the most logical choice, because the type in the Database is after all DATE.
    However this does not include the time componet. But if I change the OracleDbType.Date to OracleDbType.TimeStamp I get the time component. I'm not happy with this "hack" because I'm not sure what will happen when we upgrade our version of the Database to Oracle 9i which uses the new TimeStamp datatype.
    Is this a bug that the OracleDbType.Date does not include the time component??

    How do you examine the output Date value?
    If it is from the string, then the time components will
    not show because the NLS_DATE format in the client
    machine does not contain the time components.
    In American, the Date format is 'DD-MON-RR' by default whereas, the TimeStamp format is 'DD-MON-RR HH.MI.SSXFF AM' by default.
    Can you take a look at the time components from the OracleDate by accessing the time properties, eg. OracleDate.Hour, OracleDate.Minute..etc to see if the time values are there?
    Thanks
    Martha

  • SQL connection string reader Date time data type format

    I am using below script to fetch data fields from DB. Script runs fine but at the end receiving following error as 
    Exception calling "GetDateTime" with "1" argument(s): "Specified cast is not valid."
    At line:6 char:36
    +     $termdate = $reader.GetDateTime <<<< (23)
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : DotNetMethodException
    $sqlconstr = 'Data Source=Server;Initial Catalog=DB;User ID=User;pwd=$XXXX;'
    $sqlconn = New-Object system.Data.SqlClient.SqlConnection
    $sqlconn.connectionstring = $sqlconstr
    $sqlconn.open()
    $sqlquery1 = "SELECT * from TERMDB" 
    $SqlCmd = New-Object System.Data.SqlClient.SqlCommand ($sqlquery1,$SqlConn)
    $reader=$sqlcmd.ExecuteReader()
        while ($reader.read())
            $emp = $reader.GetString(0)
            $fn = $reader.GetString(3)
            $ln = $reader.GetString(5)
    $termdate = $reader.GetDate(24)
    "$emp,$fn,$ln,$termdate" | out-file -FilePath "C:\testing1.txt" –append
    $sqlconn.close()
            Please help with the data type required for Date time.

    Thanks.
    When i run syntax i gets below error.
    $conn = New-Object system.Data.SqlClient.SqlConnection
    $conn.connectionstring='Data Source=Server;Initial Catalog=DB;User ID=User;pwd=$XXXX;'
    $conn.open()
    PS X:\> $cmd=$conn.CreateCommmand()
    Method invocation failed because [System.Data.SqlClient.SqlConnection] doesn't contain a method named 'CreateCommmand'.
    At line:1 char:26
    + $cmd=$conn.CreateCommmand <<<< ()
        + CategoryInfo          : InvalidOperation: (CreateCommmand:String) [], RuntimeException
        + FullyQualifiedErrorId : MethodNotFound
    I will mark it as Answered & open new thread for AD cmdlet.

  • SQL Developer is not exporting the time part of date data types.

    I need to export data from a table using sql developer. The column is a date data type but when I export the data to a csv, xls or an sql file with insert statements, sql developer only includes the date part without the time.
    Please kindly advise.
    Thanks,
    Erika

    What is your 4 digits Oracle version ?
    What is your SQL Developer version ?
    With Oracle XE and a schema named TEST I have:
    select * from t
    X                        
    04-FÉVR.-2010 21:24:40  If I use Tools/Database Export with all default settings with SQL Developer 2.1.0.63 I get following SQL file:
    --  Fichier créé - jeudi-février-04-2010  
    --  DDL for Table T
      CREATE TABLE "T"
       (     "X" DATE
    --   DATA FOR TABLE T
    --   FILTER = none used
    REM INSERTING into T
    Insert into T (X) values (to_timestamp('04/02/10 21:24:40,000000000','DD/MM/RR HH24:MI:SS,FF'));
    --   END DATA FOR TABLE T
    ---------------------------------------------------Edited by: P. Forstmann on 4 févr. 2010 21:26

  • Error In IR at the time of activating data types

    I am getting an error at teh time of activating the data type
    Namespace urn:rfctoftpserver:am is not defined in the software component version SAP_ECC_DABUR_POS , 9.5 of sap.com.
    How ever I have saved the name space in Display Software component version!!
    Pls help!

    Hello,
    This problem basically happen due to the following reasons:
    1) when you try to copy the datatype from one Object to other and the namespace is not activated in course of it.
    2) If you have deleted the datatype but it still remains in the Objects list
    Resolution:
    1) Try to change the datatype name and activate
    2) if it still doesn't work have a look at the Software component relation with the datatype namespace relation

  • Adding fields with data type "TIMS" to the BP transaction

    hi all,
      This  is Anil regarding the addition of fields to the BP transaction.
    here my problem is for BP transaction I could not find any BADI or screen exit  to add the fields. Even EEWB tool does not allow us to cretate the fields with data type "TIMS". so could you please suggest any other way to add these fields to BP?
    when I enter the values to the time fields in BP transaction, they must reflect in
    BUT000 table also?
    Regards,
    Anil .

    In the physical layer, Column Properties change the data type to int.
    If still problem exists, In the Business Model, write a case statement like
    case when column1=1 then 1 end
    and apply count aggregation on the new calculated column,add the column to presentation table, use that new calculated column for report.
    - Madan

Maybe you are looking for

  • Subtitle edits lost every time iMovie is closed

    Hi, I'm working on a movie with English subtitles. Every time I close iMovie, any editing I've done of the footage itself is saved, but the work I've done on the subtitles is lost! I'm getting pretty frustrated, especially because I'll work with a na

  • Forms 11.1.1.2.1 troubleshooting with debug or trace

    Can DEBUG be configured for more info: If I add &config=debug to the end of the forms URL.. then the formsapp-diagnostic.log basically shows the clients IP, HOSTNAME, and Java Version.. nothing really usefull.. Is it possible to configure what debug

  • Can a C++ client use Oracle Standard or Oracle Enterprise version?

    Can a C++ client use Oracle Standard or Oracle Enterprise version of Coherence or is the Grid edition required? Please keep in mind that I am only interested in doing what is legal from a licensing standpoint, even if some other options are technical

  • BT HH5 Dropping All WiFi connections every few min...

    Have been with BT for over a year with no problems with standard BT Broadband and the HH4 2 days ago I was upgraded to BT 'Faster' Broadband and an engineer updated my internal phone socket and I was upgraded to the HH5 Every few minutes it drops con

  • Need a simple bit of code that will cause a somewhat slow running time

    Hey everybody. I have a class that computes the running time of code but the code I put in always comes up 1 or 0 millioseconds. I want it to be a little longer. Ive been putting in long math problems to no avail. Any suggestions?