Using Calendar class and time stamp

I am trying to generate a timestamp for posted messages using the following code:
Calendar cal = Calendar.getInstance();
int m = cal.get(Calendar.MONTH);
String dd = new String().valueOf(cal.get(Calendar.DAY_OF_MONTH));
String yy = new String().valueOf(cal.get(Calendar.YEAR));
String hh = new String().valueOf(cal.get(Calendar.HOUR));
String min = new String().valueOf(cal.get(Calendar.MINUTE));
String sec = new String().valueOf(cal.get(Calendar.SECOND));
String time = hh+":"+min+":"+sec;
However, it seem that when there's a time such as 12:02:08, the actual variable time is as follows: 12:2:8 because the leading zeros are removed? I wouldn't think using it as a String would cause that but I suppose it could be my data types. OR is there an easy way to correct this?
thanks in advance,
Chuck

You could try:
String hh = (cal.get(Calendar.HOUR) < 10) ? "0" + new String().valueOf(cal.get(Calendar.HOUR)) : new String().valueOf(cal.get(Calendar.HOUR));
As Dr Clap already said, you should probably use SimpleDateFormat. I'm sure you can use it to generate whatever formats you need for your unique filenames.

Similar Messages

  • I am using Calendar class, and want to see if a date is older then 24 hours

    i have a Calendar class instance, and i want to test if the current date & time is older then 24 hours. i have been playing with for 2 hours. anyone know how to do this?

    One way is to call .getTime().getTime() (yes, that's 2 of 'em) on the Calendar object, which converts the Calendar's time to a milliseconds value which can be compared to System.currentTimeMillis()
    The two times are within 24 h of each other if the ms values differ by less than 86 400 000.

  • Retriving records with the date and time stamp

    I need to get all the records that were update between 08:36:06 AM and 8:36:09 AM on the12/15/2009
    I am using this query it is giving me the right numbers (I think) because this condition GURMAIL_CPLN_CODE = 'UGAP', I would like something more
    precise using the date and time stamp with the dates
    12/15/2009 08:36:06 AM
    12/15/2009 08:36:07 AM
    12/15/2009 08:36:08 AM
    12/15/2009 08:36:09 AM
    select * from GURMAIL
    where
    PERMAIL_CPLN_CODE = 'UGAP'
    AND TO_CHAR(PERMAIL_ACTIVITY_DATE,'MM/DD/YYYYHH24:MI:SS AM') >= '12/15/2009 08:36%'Thank you

    Yes, but HH24 and AM cannot be used together:
    SQL> select to_date('12/15/2009 08:36:06 am', 'mm/dd/yyyy hh24:mi:ss am') from dual;
    select to_date('12/15/2009 08:36:06 am', 'mm/dd/yyyy hh24:mi:ss am') from dual
    ERRORE alla riga 1:
    ORA-01818: 'HH24' impedisce l'uso dell'indicatore meridianoUse this:
    select *
    from   gurmail
    where  permail_cpln_code = 'UGAP'
    AND    permail_activity_date between to_date('12/15/2009 08:36:06', 'mm/dd/yyyy hh24:mi:ss')
                                    and  to_date('12/15/2009 08:36:09', 'mm/dd/yyyy hh24:mi:ss')or this:
    select *
    from   gurmail
    where  permail_cpln_code = 'UGAP'
    AND    permail_activity_date between to_date('12/15/2009 08:36:06 AM', 'mm/dd/yyyy hh:mi:ss am')
                                    and  to_date('12/15/2009 08:36:09 AM', 'mm/dd/yyyy hh:mi:ss am')Max
    [My Italian Oracle blog|http://oracleitalia.wordpress.com/2009/12/18/table-elimination-oppure-join-elimination-lottimizzatore-si-libera-della-zavorra/]
    Edited by: Massimo Ruocchio on Dec 23, 2009 12:05 AM

  • How to get the most current file based on date and time stamp using SSIS?

    Hello,
    Let us assume that files get copied in a specific directory. We need to pick up a file and load data. Can you guys let me know how to get the most current file based on date and time stamp using SSIS?
    Thanks
    thx regards dinesh vv

    hi simon
    i excuted this script it is giving error..
       Microsoft SQL Server Integration Services Script Task
       Write scripts using Microsoft Visual C# 2008.
       The ScriptMain is the entry point class of the script.
    using System;
    using System.Data;
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    namespace ST_9a6d985a04b249c2addd766b58fee890.csproj
        [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
        public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
            #region VSTA generated code
            enum ScriptResults
                Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
                Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
            #endregion
            The execution engine calls this method when the task executes.
            To access the object model, use the Dts property. Connections, variables, events,
            and logging features are available as members of the Dts property as shown in the following examples.
            To reference a variable, call Dts.Variables["MyCaseSensitiveVariableName"].Value;
            To post a log entry, call Dts.Log("This is my log text", 999, null);
            To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, true);
            To use the connections collection use something like the following:
            ConnectionManager cm = Dts.Connections.Add("OLEDB");
            cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;";
            Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
            To open Help, press F1.
            public void Main()
                string file = Dts.Variables["User::FolderName"].Value.ToString();
                string[] files = System.IO.Directory.GetFiles(Dts.Variables["User::FolderName"].Value.ToString());
                System.IO.FileInfo finf;
                DateTime currentDate = new DateTime();
                string lastFile = string.Empty;
                foreach (string f in files)
                    finf = new System.IO.FileInfo(f);
                    if (finf.CreationTime >= currentDate)
                        currentDate = finf.CreationTime;
                        lastFile = f;
                Dts.Variables["User::LastFile"].Value = lastFile;
                Dts.TaskResult = (int)ScriptResults.Success;
    thx regards dinesh vv

  • How do you date and time stamp iCal entries?  We share an event calendar and need to know when a new event was entered into iCal.

    How do you date and time stamp iCal entries?  We share an event calendar and need to know when a new event was entered into iCal.

    BKBK,
    Thank you for your response. That does adequately cover the
    client-originated sessions, but still leaves the ability I am
    looking for unavailable.
    It did serve to definitively answer my most pressing
    question, however, with this statement:
    Note: ColdFusion cannot create a session if an initiator
    application uses a SendGatewayMessage method to start an
    interaction with a client, such as an SMS user. In this case, the
    sending code must keep track (for example, in a database) of the
    messages it sends and their destinations. When a response event
    arrives, it can look up the origniatorID to determine whether it
    was in response to an outgoing message.
    I will play around with the Application scope to see if there
    might be a workable solution there.
    RLS

  • How do you date and time stamp pictures and videos using a EOS Rebel T3?

    I am needing to utilize date and time stamping on videos and photos in my work.  The pictures and videos must display time, a date, and reference number.  I have gone through the cd, owner's manuel and software manuel and I am unclear if I can perform this function. 

    While this is a relatively common feature on point & shoot cameras -- where the photo is thought of as a snapshot to document a memory in a person's life, among DSLR cameras it's not very common (I don't actually know of a DSLR that does this though I don't doubt that it may exist).  DSLR users are usually expecting a higher quality image -- so now the image is thought of more like art and less like a snapshot and the date/time in the corner distracts from the image.  Also they tend to be more advanced users who would be able to modify the image themselves so they have little need for such a feature.
    The camera does record the date & time... but it's in the EXIF data (information recorded into the image file but not displayed).  
    SO... there are programs that will just do this.  You'll need to do a search (I found several but have never tried one so I can't vouch for them).  I think there are Photoshop plug-ins that do this (assuming you have Photoshop). These programs allow you to define the info you want printed (including EXIF data such as date/time) and you get to pick the location, font, size, color, etc. and ultimately the location on the image where you'd like the info displayed.  They then add the info visibly onto the image for you and most support "batch" use (e.g. drop a whole folder of images on it and they'll do them all.)
    Tim Campbell
    5D II, 5D III, 60Da

  • How do you edit out the date and time stamp from a photo

    How do you edit out the date and time stamp from a photo

    You can blur it out with retouch
    The built-in "Retouch" brush in "Edit" mode should suffice, if the background is mostly uniform, and if you set the size of the brush to slightly wider than the bar width of the letters. For example, in this picture I removed the year from the date (in the lower right corner) by using the "retouch" brush and following the contours of the letters. (the screen shot is from iPhoto '11, but iPhoto 9 should give similar results).
    Regards
    Léonie

  • DATE and TIME Stamps

    I'm a relative newbie still having issues with getting date and time stamps on my printed documents.
    I use Preview, Pages, Numbers and also tend to print to PDF a lot, which I am opening in Preview.
    I have found an "Insert" ability in Pages but for some reason it appears to only give me the date that I inserted the Timestamp.
    Can anyone help me figure out my options in Mac for putting the following on a document:
    A. DATE and TIME printed
    B. NAME of document with LOCATION (I assume this is software specific?!)
    Thanks for any help with this.
    - Jon

    Yes, ...and I was hoping to find a solution since I sometimes have the same problem!
    But I'm afraid there is none. For sure I didn't find any fxscript function returning Date&Time. At the moment the best solution I know is what you suggested, Ian: capture twice, once in FCE for editing and once in iMovie for reading Date and Time.
    I'd be glad to write and share a plugin displaying date and time if somebody is able to tell me what fxscript function (if any) should I use...
    Piero

  • How to provide date and time stamp to the extracted file.

    I 'm downloading data from DB to Flat file using GUI_DOWLOAD. whenever it is executed it is creating with a file name.
    if i rerun the program the file is overwriting with the same name.
    now based on the requirement how many times i executed, that many times file should be individually created and should be added with date and time stamp.
    like
    if when i executed  at the very first time it should saved with filename, date and time.
    say "Address.txt 04/05/2007 07:55:10"
    When i executed it for second time it doesn't overwrite the file.
    it should create a new file.
    like "Address.txt 04/05/2007 07:59:20".
    Please guide me the way if possible code.
    Thanks in advance.

    Hi Vamsi,
                   Use FM 'F4_PROGRAM' to take file from the user .
    In this case user will enter the file name. u can append date & time to that file path.
    Refer this code.
    CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          PROGRAM_NAME  = SY-REPID
          DYNPRO_NUMBER = SYST-DYNNR
        IMPORTING
          FILE_NAME     = P_P_FILE.
    concatenate P_FILE '04/05/2007 07:59:20' into V_FILE.
    CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                        = v_file
         filetype                        = 'ASC'
          write_field_separator           = 'X'
        TABLES
          data_tab                        = i_tab
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      IF sy-subrc = 0.
        MESSAGE i002.
      ENDIF.
    Reward points if helpful.
    Regards,
    Hemant.

  • Date and time stamp with Sony HDR CX7

    Hi,
    I am trying to figure our how to find date and time stamps for individual clips.
    My workflow is as follows: I use disk utility to make a disk image (.dmg) of the memory stick and import the clips from this disk image. Everything works fine, but I am not able to find any date and time information on the imported clips.
    I am slowly building a large archive of these disk images and I am wondering whether I need to add some some date an time info manually. I know that this information is recorded on the memory stick as the camera can display them.
    Thomas
    Config:
    Sony HDR CX7
    Final Cut Express 4
    OS X 10.5
    MacBook Pro 2.4GHz

    I'd also like to ask if it's really necessary that the statuses within the status profile and date profile should maintained in the same positions.
    No

  • Date and time stamp in array

    Hello,
    I am using Labview 8.0 and I would like to include a date and time stamp each time data is collected and include this as a 5th column in the final array.  I inserted a random number generator instead of devices so it would be easier to understand and test.  I am new to Labview and have never created a date/time stamp before.  Any help or advice would be appreciated.
    Dave
    Solved!
    Go to Solution.
    Attachments:
    Timestamp.vi ‏16 KB

    Yes you need to convert all to strings since the timestamp in HH:MMS is a string.  In the string palette, there is a sub-palette full of numeric to string conversion tools.  Use the Number to Fractional String to convert all numerical data to strings.  Use the Format/Date Time String function (found in Timing palette) to convert the timestamp to HH:MMS.  See the format string in my example.
    - tbob
    Inventor of the WORM Global
    Attachments:
    TimestampAssistance[1].vi ‏14 KB

  • Date and time stamp transfer via Firewire

    Hi
    Having issues with a Sony micromv camcorder transferring digital recordings via fire wire to Apple macbook- the files are transferrred without the date and time stamp on it. Any way around the problem. Thanks

    ebigglesworth,
    I too am curious about Frank's mention of the date and time removal tool.
    As an aside to your comment:
    I'd rather just be able to tell aperture I don't want the time stamp on the image, to remove it some how digitally, if that makes sense. You'd think it could just be backed out in some fashion.
    That's impossible. Your camera made it impossible. Your camera threw out some pixel data of the real picture in favor of replacing it with yellow, white, and black pixels (or whatever color your timestamp is). Basically, the original photo information is completely lost. All you can do is smudge things (in one way or another) and make the best of it. It will never look completely right unless you use a pixel editor (which Aperture is not) and painstakingly put color in, pixel-by-pixel.
    nathan

  • Date and time stamp question

    Is there a way to drag the "date and time stamp" to my project all at once, or do I have to continue to drag it to each individual section of my project?
    Thanks

    Hi,
    I don't find any function module, but it does'nt really hard to code this using DIV and MOD instructions :
    If you've got your time in seconds :
    w_day = w_time DIV 86400.
    w_mod = w_time MOD 86400.
    w_hour = w_mod DIV 3600.
    w_mod = w_mod MOD 3600.
    It doesn't seem too bad in term of performance....
    Mathieu

  • Date and Time Stamp Removal?

    Does anyone know how to digitally remove the date and time stamp on the face of the photo once the photos are loaded in Aperture, short of doing re-touch? Working in Aperture 3.

    ebigglesworth,
    I too am curious about Frank's mention of the date and time removal tool.
    As an aside to your comment:
    I'd rather just be able to tell aperture I don't want the time stamp on the image, to remove it some how digitally, if that makes sense. You'd think it could just be backed out in some fashion.
    That's impossible. Your camera made it impossible. Your camera threw out some pixel data of the real picture in favor of replacing it with yellow, white, and black pixels (or whatever color your timestamp is). Basically, the original photo information is completely lost. All you can do is smudge things (in one way or another) and make the best of it. It will never look completely right unless you use a pixel editor (which Aperture is not) and painstakingly put color in, pixel-by-pixel.
    nathan

  • UCM API Methods for PDF Water Marking and Time stamping ???

    hi,
    i am working on project, the requirment is we need to migrate from DMS (DIGI SAFE) To UCM.
    here we need to approch through API, it should not through tool based functionality. document should be water marked and time stamped when we retrived the document through CIS.
    is there ant UCM API's for water mark and time stamp ??? please provide the methods for it. is there any API mehtods for Document versioing ??
    i am presently working windows 7 OS ? i am trying to install UCM 10gR3 in Windows 7 OS, will it support for UCM ??
    any help would be apprciated.
    Regards,
    YT

    Hi,
    There are services in Content Server that will allow you to create revisions of existing items. For example, CHECKIN_UNIVERSAL service will check in a new revision of an item if that Content ID already exists. You can also checkout a document if needed using the CHECKOUT service. Please refer to the services reference guide for more details (http://download.oracle.com/docs/cd/E14571_01/doc.1111/e11011/toc.htm).
    Regarding conversion and watermarking...
    You don't have to call a service to convert or watermark a document. These features have to be configured on the server. If you configure the content server to convert Word documents to PDF, then whenever a Word document is checked in, the content server will automatically convert it to PDF. In addition, if you have PDFWatermarking enabled and configured, watermarks will be applied automatically as well. All you have to do is ensure the product is configured correctly for the formats you want, and then check in the document. When you retrieve a document (using the GET_FILE service for example), you can ask for the PDF version by passing additional parameters.
    Please review the Application Administrators Guide (http://download.oracle.com/docs/cd/E14571_01/doc.1111/e10978/toc.htm) for info on enabling and configuring PDF Watermarking.
    The doc links referenced above are for UCM 11g. The same docs are available for 10gR3 at http://download.oracle.com/docs/cd/E10316_01/ouc.htm.
    --Vijay                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • After iTunes 7.6 update, iPhone is not recognized by iTunes

    I plugged in iPhone after iTunes update and a dialog box popped up that says "An iPhone has been detected, but it could not be identified properly. Please disconnect and reconnect the iPhone, then try again." Phone is 1.1.3 firmware (update earlier i

  • Updated itunes-accidentally deleted borrowed music from other itunes

    I updated my itunes settings by changing manual updates to automatic. In doing this I accidentally deleted music on my ipod that I obtained from friends' itunes. Is there any way to salvage the lost music?

  • Production report displaying months

    hi , can anyone help me in getting month wise production report...  i e from jan to dec.... it shoulld display all months and show month wise production.... example ITEM ITEM DESCRIPTION   JAN FEB MARCH DS01   SCREW                 10     10       30

  • XApp Analytics SCM: error in BEx query definition

    I'm configuring the <i>SAP xApp Analytics for SCM</i>. The BEx query <i>Warehouse Stock Analytics – Inventory Turnover</i> (0IC_C03_Q0024) is used in this application. It fetches data from the material movement BI InfoCube (0IC_C03). Apparently there

  • Programmatic dataset as data source?

    Post Author: mervrutt CA Forum: Data Connectivity and SQL I need to use a program-created dataset as a data source for a web report.  I can't connect directly to a database because my dataset is provided by a COM+ object, which I display in a gridvie