Format Time to Time/ Date to Date

Hi,
need some help. I try to format a Time and a Date value, but I don't want to convert them to a String.
I know this:
SimpleDateFormat formatDate = new SimpleDateFormat( "dd/MM/yyyy" );
SimpleDateFormat formatTime = new SimpleDateFormat( "HH:mm:ss" );
String strDate = formatDate.format( new Date() );
String strTime = formatTime.format( new Date() );
But instaed of "String strDate" and "String strTime" I want something like "Date dDate" and "Time tTime".
Do someone know, if it's possible?
Thanks in advance for your help....

Hi ChuckBing,
I have to insert/update a Date field in a recordset in a MS Access database. The problem is that the date must be formatted (dd/MM/yyyy) and the time also (HH:mm) - without seconds.
I can do something like this:
String strInsert = "INSERT INTO table"
+ "( Date, Time ) "
+ "VALUES "
+ "( "
+ "#" + strDate + "#" + ", "
+ "'" + strTime + "'"
+ " )";
stmt = con.createStatement();
stmt.executeUpdate( strInsert );
And this:
String strUpdate = "UPDATE table"
+ "SET Time = '" + strTime + "'"
+ " "
+ "WHERE "
+ "Date = " + "#" + strDate + "#"
+ " AND "
+ otherCriteria;
stmt = con.createStatement();
stmt.executeUpdate( strUpdate );
But this solution is bad. And this:
ResultSet rs = stmt.executeQuery( aQuery );
rs.moveToInsertRow();
rs.updateString( "Datum", "#" + strDate+ "#"); // doesn't work
rs.updateString( "Kommt", "'" + strTime + "'" ); // doesn't work
rs.insertRow();
rs.moveToCurrentRow();
doesn't work, because I can't write a String into a Date field on this way.
Do you know, what I'll try to explain?

Similar Messages

  • How can i get todays date as an yyyy-MM-dd format instead of Time stamp

    how can i get todays date as an yyyy-MM-dd format instead of Time stamp,i try to do it in the fallowing way
    <code>
    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
         java.util.Date d = new java.util.Date();
              String s = d+"";
    Calendar cal1 = Calendar.getInstance();
         try{
         cal1.setTime(sdf.parse(s));
    }catch(Exception e){}
    </code>
    but i could not able to get,it throws error as an java.text.ParseException: Unparseable date: "Thu Jan 24 11:43:32 EST 2002" ,pl suggest me any solution.any help would be appreciated.
    Regards.

    Does string s have to end with ""?
    Try doing sdf.format(d) instead.

  • I would like to format cells with time only.  when I enter a time of day the current date is still in the cell which is not necessarily so

    I would like to format cells with time only.  when I enter a time of day the current date is still in the cell which is not necessarily so.  THere are  no options for just  date .

    christine275 wrote:
    ... (this is a time worked by date and not always entered on the date worked)--
    "Time" in Numbers is always "Time of Day", and is always part of a Date and Time value. "Amount of Time" is a Duration value, which may be displayed in a similar format to "Time of Day," but is a different type of value.
    If you are entering the number of hours and minutes worked, format the column as Duration, set the units and the format in which you want to have the value appear.
    The Date column will still contain a Date and Time value (Jan 1, 2011 00:00:00 in the cell shown in the example), but the "Time Worked" cells will contain only a Duration value.
    Incidently, the Date in A2 was entered as "jan 1" (without the quotes). Numbers automatically adds the current year and the default time value, then displays the result in the closest format to what you've entered, or in the Date and Time format you have chosen.
    The Duration value in B2 was entered as 3:15 (as displayed). Note that in the entry bar the duration is displayed as 3h 15m, probably to distinguish it from a similarly formatted (Date and) Time value.
    Regards,
    Barry

  • Issue: format / "language" of current Date (in date/time field), javascript only

    Hi,
    I have 2 date fields in my form, which should display the date in differnt format. (yyyy.mm.dd /  dd-mm-yyyy)
    To get the current date I use java script only
    Formular1.p1.date_YYYYmmDD::initialize - (JavaScript, client)
         var date = new Date();
        this.rawValue  =  date.toLocaleDateString();
    My first problem is (red): I get date in English, but I want it in a different language. As it was set in form settings
    My second issue is: how can I format a date/time-filed (not a text field) in javascript with a specific pattern on init-event?
    It seems my code in init-event overrides the pattern configuration of the date/time-field
    Here is my form, if anyone want to check it:
    https://acrobat.com/#d=zeOMyj9MhBdYbVWk8S1pHw

    Hi,
    I think both problems are the same, when setting a date/time field using the rawValue the format always has to be yyyy-mm-dd, if you use any other format the value is just treated as text and displayed without formatting.  
    var date = new Date();
    this.rawValue = util.printd("yyyy-mm-dd", date);
    You can also set the formattedValue if you have a date in the correct format. 
    var date = new Date();
    var currentLocale = xfa.resolveNode("#localeSet.#locale").name;
    var dateFormat = "date("+currentLocale+"){DD MMM, YYYY}"
    this.formattedValue = util.printd(dateFormat, date, true) 
    This code assumes the display pattern is date{DD MMM, YYYY}
    The date format specification is in the XFA Spec http://partners.adobe.com/public/developer/xml/index_arch.html
    Regards
    Bruce

  • How to prevent user to enter data in "Date/Time Field"?

    Hi folks,
         Back after long time to the forums, where I get answers which are helpful in making me good at utilizing designer.
         I am trying to validate the "Date/Time Field" using JavaScript but couldn't get a proper RegEx expression for various invalid user input formats. If anyone can help me out in finding a proper script that would Great.
         My script grown bigger and bigger to accepting invalid dates, but felt like hardcoding. So, instead I decided why can't we prevent a user to enter data into "Date/Time Field" and use only calendar dropdown. Is there is a way to do this?
    find my sample testing docment
    https://acrobat.com/#d=mYXkrhO2txuEesCfmvxNXg
    Thanks in Advance,
    Rajesh

    Hi Rajesh,
    I don't think there is a way of stopping the user from using the keyboard to enter a date.  You can use the following script in the change event to stop them typing a date but they will still be able to paste a date in.
    if (xfa.event.change.length === 1)
    xfa.event.change = "";
    This code works because if the date is selected from the calendar dropdown then the date xfa.event.change value will be the whole date and therefore longer than one character.
    I couldn't access your sample but if you were to set an display picture for the date field to something other than date{YYYY-MM-DD} then a valid date will have a formattedValue that is different than the rawValue.
    Dave

  • Date Modified Date/Time Issues on Files Exported to Excel

    Hello -
    I am using Crystal Reports XI, Release 2 and Visual Studio 2005 Enterprise Edition for my ASP.NET application.
    CrystalReports dll version : 11.5.3700.0
    .NET Framework 2.0.50727
    I use the CrystalDecisions.CrystalReports.Engine.ReportDocument to export a report to Excel (ExportFormatType.Excel).
    When you view the exported file in Excel 2007 (just open and close it, making no changes), the Date Modified date of the file changes to whatever date/time the file was last viewed.  I have also noticed this same behavior when exporting to Excel from Crystal, using a vendor desktop application that is written in C++ and uses Crystal XI.
    Does anyone else experience this issue and have a resolution?
    Edited by: Meg Thickman on Feb 3, 2009 8:59 AM

    Hi Meg,
    Just to clarify did you mean viewing the PDF?:
    "Why would/should the file system date change merely by viewing the report?"
    Our exported files are not linked to the master RPT file.
    As I indicated the XLS file is likely in an older format and Excel is detecting and updating something which the file system then detects a change and updates the date stamp. Or excel is writing something back to the file. Did you notice if the file size changed or possibly the byte hash?
    This is not something we are going to be able change. For compatability reasons we cannot stop Excel from updating the file.
    As a work around add the Data Date field to your reports and your auditors can use that as the reference. It will reflect the actual date and time the report was run. Or use Excel API's to update the file format once the report has been exported in your code. You may also want to check with Microsoft to see if it's an option in Excel not to update the format or possibly a registry key to disable the option.
    Thanks again
    Don

  • Time Zone for a particular date/time and location

    Hi,
    Consider this:
    You have some date stored somewhere (e.g. in a database), and it is stored in UTC. Now, you want to display that date in the local time at that particular time, e.g. with or without daylight savings depending on the time of year.
    A more concrete example:
    In Perth, Australia, daylight savings goes from Dec to Feb inclusive (approx).
    Now, you have two dates, say 2007-01-01T12:00:00+0000 and 2007-05-01T12:00:00+0000.
    You would like to display these dates as:
    2007-01-01T21:00:00+0900 and 2007-05-01T20:00:00+0800 respectively.
    However, given that the current timezone today (26th June) in Perth is +0800, they will be displayed as:
    2007-01-01T20:00:00+0800 and 2007-05-01T20:00:00+0800 respectively.
    Code for displaying in current timezone follows, as a starting point:
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.ArrayList;
    import java.util.Calendar;
    import java.util.Date;
    import java.util.GregorianCalendar;
    import java.util.List;
    import java.util.TimeZone;
    public class TimeZoneTestMain
         * @param args
        public static void main(String[] args)
            // UTC timezone.
            TimeZone utcTZ = TimeZone.getTimeZone("UTC");
            // Collection of dates.
            List<Calendar> dates = new ArrayList<Calendar>();
            // Create a date/time - 10 Dec 2005 12pm UTC
            Calendar cal1 = new GregorianCalendar(2005, Calendar.DECEMBER, 10, 12, 0);
            dates.add(cal1);
            cal1.setTimeZone(utcTZ);
            // Create a date/time - 10 Dec 2006 12pm UTC
            Calendar cal2 = new GregorianCalendar(2006, Calendar.DECEMBER, 10, 12, 0);
            dates.add(cal2);
            cal2.setTimeZone(utcTZ);
            // Create a date/time - 10 Apr 2007 12pm UTC
            Calendar cal3 = new GregorianCalendar(2007, Calendar.APRIL, 10, 12, 0);
            dates.add(cal3);
            cal3.setTimeZone(utcTZ);
            displayDates(dates);
        private static void displayDates(List<Calendar> dates)
            DateFormat utcDF = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
            utcDF.setTimeZone(TimeZone.getTimeZone("UTC"));
            DateFormat waDF = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
            waDF.setTimeZone(TimeZone.getTimeZone("Australia/Perth"));
            for (Calendar cal : dates)
                Date date = cal.getTime();
                System.out.println("UTC date: " + utcDF.format(date)
                                   + ", WA date: " + waDF.format(date));
    }Output is:
    UTC date: 2005-12-10T12:00:00+0000, WA date: 2005-12-10T20:00:00+0800
    UTC date: 2006-12-10T12:00:00+0000, WA date: 2006-12-10T20:00:00+0800
    UTC date: 2007-04-10T12:00:00+0000, WA date: 2007-04-10T20:00:00+0800
    I would like the output to be (daylight savings only came in for WA in 2006):
    UTC date: 2005-12-10T12:00:00+0000, WA date: 2005-12-10T20:00:00+0800
    UTC date: 2006-12-10T12:00:00+0000, WA date: 2006-12-10T21:00:00+0900
    UTC date: 2007-04-10T12:00:00+0000, WA date: 2007-04-10T20:00:00+0800
    Cheers

    >
    might be problem with jdk version which you are
    using!!!
    Mine is jdk 5You are right - just tried with 1.6.0_01-b06 and all is good.
    For some reason it didn't occur to me that the other version of the JVM I was using wouldn't have the daylight savings rule, which would make sense since it was released before the daylight saving legislation was introduced by the WA state government!

  • Time field also displaying current date

    Hi there
    I have two databound fields (to a Sybase back-end) - one is a date field, the other a time field!
    The date field works fine, but the time field is displaying the current date as well as the data retrieved time!
    The field is set to:-
    Data pattern: HH:MM::SS
    Data Format: Time
    Type: Date/Time Field
    Validation Pattern: HH:MM:SS
    The field is defined as 'time' in Sybase, and displays just the time in other objects (.NET fields...).
    Anyone any ideas?

    not the cleanest code, but i had this laying around in an old
    project...
    date = new Date()
    month = date.getMonth() + 1
    today = date.getDate()
    fyear = date.getFullYear()
    hours = date.getHours()
    minutes = date.getMinutes()
    seconds = date.getSeconds()
    if(month <10){
    month = "0"+month
    if(today<10){
    today = "0"+today
    if(hours <10){
    hours = "0"+hours
    if(minutes <10){
    minutes = "0"+minutes
    if(seconds <10){
    seconds = "0"+seconds
    CurrentTime.text = month+"/"+today+"/"+fyear+"
    "+hours+":"+minutes+":"+seconds

  • END ROUTINE to calculate time differnce for two corresponding dates

    Hi All,
    I have to write an END ROUTINE in which I have 2 DATE FIELDS (e.g. DATE_1, DATE_2) and corresponding TIME fields (e.g. TIME_1, TIME_2).
    I have to calculate difference between the TIME fields for the two dates and populate a TIME_DIFF field.
    Can someone pls help me by posting sample code as i am new to BI.
    Thanks in ADVANCE!!!

    End Routine:
    http://help.sap.com/saphelp_nw70/helpdata/EN/e3/732c42be6fde2ce10000000a1550b0/frameset.htm
    End Routine and Expert Routine
    Thanks..
    Shambhu

  • Can we use Time Machine to back up data on Time Capsule from the outside of network?

    I have Time Capsule at home.  Can I use Time Machine to back up data of portable nootebook when I am working at office?

    If you mean over the internet, you can but it will be so slow and more than likely so unreliable it is a poor method to use. Remember all internet is limited to upload speed.
    Lion does a temporary backup onto local hard disk.. which is useless of course if the hard drive is damaged.. but helps if you delete an important file. Then when you go back home and it discovers the TC is available it will then backup again from where it left off.
    I think it is only a major issue if you are away from home for major lengths of time, weeks or months.

  • How can I generate a real-time highchart from my database data?

    I have looked several links; however, I couldn't find a working demo showing how to implement a highchart using data from a database.
    Objective: I want to generate a real time highchart line graph getting data from my database. What I want is very similar to the
    HighChart Demo which provides a real-time highchart with randomly generated values. It is also similar by X-axis and Y-axis, for I want my x-axis to be "Time" (I have a DateTime column in my database) and y-axis to be an integer (I have
    a variable for that as well in my database).
    Please I need help in sending the model data to my razor view.
    Note that I am already using SignalR to display a realtime table. I also want to know if it can be used to automatically update the highchart as well.
    Below is the code snippet of my script in the view. I have used the code provided in
    HighChart Demo link for generating the highchart. Please tell me where should I apply the changes on my code.
    @section Scripts{
    <script src="~/Scripts/jquery.signalR-2.2.0.js"></script>
    <!--Reference the autogenerated SignalR hub script. -->
    <script src="~/SignalR/Hubs"></script>
    <script type="text/javascript">
    $(document).ready(function () {
    // Declare a proxy to reference the hub.
    var notifications = $.connection.dataHub;
    //debugger;
    // Create a function that the hub can call to broadcast messages.
    notifications.client.updateMessages = function () {
    getAllMessages()
    // Start the connection.
    $.connection.hub.start().done(function () {
    alert("connection started")
    getAllMessages();
    }).fail(function (e) {
    alert(e);
    //Highchart
    Highcharts.setOptions({
    global: {
    useUTC: false
    //Fill chart
    $('#container').highcharts({
    chart: {
    type: 'spline',
    animation: Highcharts.svg, // don't animate in old IE
    marginRight: 10,
    events: {
    load: function () {
    // set up the updating of the chart each second
    var series = this.series[0];
    setInterval(function () {
    var x = (new Date()).getTime(), // current time
    y = Math.random();
    series.addPoint([x, y], true, true);
    }, 1000);//300000
    title: {
    text: 'Live random data'
    xAxis: {
    type: 'datetime',
    tickPixelInterval: 150
    yAxis: {
    title: {
    text: 'Value'
    plotLines: [{
    value: 0,
    width: 1,
    color: '#808080'
    tooltip: {
    formatter: function () {
    return '<b>' + this.series.name + '</b><br/>' +
    Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) + '<br/>' +
    Highcharts.numberFormat(this.y, 2);
    legend: {
    enabled: false
    exporting: {
    enabled: false
    series: [{
    name: 'Random data',
    data: (function () {
    // generate an array of random data
    var data = [],
    time = (new Date()).getTime(),
    i;
    for (i = -19; i <= 0; i += 1) {
    data.push({
    x: time + i * 1000,
    y: Math.random()
    return data;
    function getAllMessages() {
    var tbl = $('#messagesTable');
    var data = @Html.Raw(JsonConvert.SerializeObject(this.Model))
    $.ajax({
    url: '/nurse/GetMessages',
    data: {
    id: data.id,
    contentType: 'application/html ; charset:utf-8',
    type: 'GET',
    dataType: 'html'
    }).success(function (result) {
    tbl.empty().append(result);
    $("#g_table").dataTable();
    }).error(function (e) {
    alert(e);
    </script>

    Hi Sihem,
    Thank you for contacting National Instruments.  Using the LabVIEW Real-Time module, you can do development without actually having a target.  While viewing the project explorer window, you can do the following steps:
    Right click on the project
    Select New >> Targets and Devices
    Select the "New Target or Device" radio button
    Select the target you would like to develop on.Information about the LabVIEW Real-Time Module can be found here.
    Regards,
    Kevin H
    National Instruments
    WSN/Wireless DAQ Product Support Engineer

  • Is there any object in labview that contains a list of data for the user to select (selection one at a time) or add a new data?

    Is there any object in labview that contains a list of data for the user to select (selection one at a time) or add a new data?

    List and table controls -> listbox..is that what you are thinking of?
    The listbox presents the user with a list of options, and you can set it to only accept one selection at a time...Adding new data to the list can not be done directly by the user but if you make e.g. a text control and a button you can programatically insert new objects described in the text box when the button is pressed...(see example).
    If you need more than one column you have the multicolumn listbox. If you want the users to write new entries directly yu can use a table and read selected cells using it's selection start property to read what cell has been selected.
    MTO
    Attachments:
    Listbox_example.vi ‏34 KB

  • HELP!!!!   How to read data from a file at time to time?

    i store temporary string data in a file(the data changes always), and i need to read the data in the file from time to time, so how can i read from the file like every 5 seconds?

    Please i need your help mr. noahw. i have a timer called timer1 inside that timer i am starting a thread to read the data in a file to me, then i have another timer timer 2 in which it takes the data already read from timer 1 and draws them on a GUI. the problem with me is that, i am unable to set a correct time for each of the two timers such that, every time timer one executes that is a new data is generated i need to draw only one figure coreesponding to those data, then when a new set of data is read i need to draw another figure based on the new data read, please help me with this becasue i need it urgently, this is my email, [email protected], and i can offer this reply as many points as you want if this helps you to help me, i am counting on you.

  • Time machine ballsed after up date 10.5.3

    Well, I'll bang this here although I suppose there is little anyone can do to help.
    I have months worths of backups in time machine for mac book stored on my airport extreme harddrive. After the update and even if I manually mount the drive and the sparse bundle for my mac book time machine does not see the volume and will not back up.
    Not the end of the world as I have not lost data, but still a peeve.

    I am having the same problem.
    I make backups prior to installing any updates... so Time Machine / Time Capsule had just performed a backup prior to installing 10.5.3 (so I know it was working). I waited for Time Machine to completely finish and show that it was just waiting for the next backup interval before I started the update.
    After the 10.5.3 update, it can no longer mount my sparse image. I'm attempting to mount it manually -- so far it's been hanging on: Opening <name of sparse bundle image> for the last 45 mins or so.

  • I have not been able to back up for2 days.  Time machine error message: /Volumes/Data/David's MacBook Air.sparsebundle" is already in use.

    I have not been able to back up for2 days.  Time machine error message: /Volumes/Data/David’s MacBook Air.sparsebundle” is already in use.
    What now?
    Macbook Air.
    Was working fine for the past year until now.

    See more like this on the right.. this is the most common error reported here since mountain lion came out..
    Or read C12.. http://pondini.org/TM/Troubleshooting.html
    Or just restart the whole network.. in right order from off.. modem.. router / TC.. clients 2min gap.

  • Does the data transfer used in the back up in time capsule included in the data allowance from my service provider?

    Is the data transfer used in the backup with airport time capsule included in the data allowance with my service provider?

    gheefromsa wrote:
    I am using Ethernet cable to connect TC to the modem. I am only backing up my mac book air within range of the TC. So I guess it will be OK from your reply. As a trial I did interrupt the back up by turning off the TC, disconnecting the Ethernet cable, turning TC back on. The mac would not connect wirelessly with the TC without the Ethernet connection.
    It is not using ISP .. absolutely for sure. Well 99.999%.. absolute tends to be only in maths.
    But you did the test wrongly.. I said to disconnect the modem.. during the backup.. not turn off the TC.. obviously once interrupted the TC will not work again until everything is plugged in.. but it will work even bridged for a short time.. just unplug the WAN port from the modem.
    The test is moot now.. as I can give you a 99.999% promise it is not using ISP.

Maybe you are looking for

  • Validate and allow null

    Hello: I created a validation, that would check the item to make sure that no negative numbers are entered. But also if the item is left null that would be acceptable. The problem I am having is : Item 1 now does not accept negative numbers which is

  • T520 - Win7 Ent - UEFI - GPO Enabled to allow Bitlocker enhanced pin, but windows refuses it

    Before I start -- I'm not sure if this is a windows issue or a lenovo issue, but had to start somewhere. I have installed our standard image of Windows 7 enterprise using Microsoft Deployment Toolkit on a new T520.  The drive is configured for and OS

  • Configure backup device in SAP(DB13)

    I have installed the ECC 6.0 with SQLServer 2005 ,now I want to configure the backup device in it. I am using external hdd for backup. Please suggest me how to configure backup device in SAP(DB13) and database level. where I have to set the parameter

  • HOLAP - using OBIEE and Oracle OLAP

    Hi How to implement HOLAP in OBIEE (with Oracle OLAP cubes) as below – 1. For an aggregate table, there are 3 dimensions each one having 4 levels within its hierarchy. 2. We create an aggregate table at the lowest level of each dimension. 3. We creat

  • Editing photos with Aperture....how to...?

    Ok so I have two photos, I want to put them both together...one completes the other or is a continuation...how in heavens do I do this with Aperture? can I even do this? I am used to photoshop...I am not sure how to go about combining two photographs