LastModified()  to millisec

Hi form
Is there a API to convert date/time format for File.lastModified() to milli sec
starting from 01-01-1970
or How can this be achieved ??? --- ( : + ]
Thx in advance

Hi form
Sorry to Get t u confused...........
u are correct...
> if your problem is to convert any date string to long, you must first construct a Date
> object using SimpleDateFormat object and use it to get the long value.
This is what I need ,I have to reverse the avaliable date,
Date in this Format "Thu Dec 02 11:41:57 GMT+05:30 2004"
To
Date in millisec ... 1101967917437
So u say using simple date format can achieve this .
Can u Please Explain with a code snippt
Thx in advance

Similar Messages

  • File.lastModified() not working properly.

    Hi,
    I need to check if the file is modified or not.So Iam using the following code.
    public void testLastModified() {
              for(int i =1 ;i < 10 ;i++){
              String filePath = "C:" + File.separator + "test1.rtf";
              File test1 = new File(filePath);
              if (test1.exists()) {
                   System.out.println("File exits");
                   if (test1.canRead()) {
                        System.out.println("Can read file");
                        if (test1.canWrite()) {
                             System.out.println("can write file");
                             long time = test1.lastModified();
                             System.out.println("last modified:" + time);
                             try {
                                  this.sleep(1000);
                             } catch (InterruptedException e) {
                                  // TODO Auto-generated catch block
                                  e.printStackTrace();
                             System.out.println("wait completed");
                             System.out.println("last modified:" + test1.lastModified());
    while the thread is in sleep state for 1000 ms iam openning and modifying the file.But not saving it.
    The code prints the same modified time as that of the intial modified time.
    So can't we determine last modified time without saving the file.
    Thanks in advance.

    The question doesn't make any sense at all. If you haven't saved the modifications yet, the file hasn't been modified yet, so how could the last-modified date & time change? Why should it change?
    Having said that, some platforms don't modify this attribute until the file is closed.

  • Formatting the return value of: File(myFile).lastModified()

    I'm checking file date and time stamps:
    myDate = File(myFile).lastModified()Is there a way to format the return value?
    myDate equals: 1205166439145I'd like to see something like:
    03/10/2008  12:27 PMI'm using the following code to print the value:
    System.out.println(myDate);

    Awesome! I really, really appreciate the help and the sample code!
    Successful Output:
    K:\COMMON\ITS\STEVEB\java\CompareFileDates>java CompareFileDates
    execution continuing...
    test1.steve (3/10/08 12:27 PM) is older than test2.steve (3/10/08 1:33 PM)Error free code:
    import java.io.File;
    import java.lang.Object;
    import java.util.Date;
    import java.text.Format;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    public class CompareFileDates {
      public static void main(String[] args) {
        String file1_stat = null;
        String file2_stat = null;
        String file1 = "test1.steve";
        String file2 = "test2.steve";
        long date1 = 0;
        long date2 = 0;
        String finalDate1 = null;
        String finalDate2 = null;
        boolean file1Exists = (new File(file1)).exists();
        if (file1Exists) {
            // File or directory exists
            file1_stat = "does exist";
            // Get the timestamp from file 1 and format it
            date1 = (new File(file1)).lastModified();
         Date newDate1 = new Date(date1);
         DateFormat df = new SimpleDateFormat();
         finalDate1 = df.format(newDate1);
         //System.out.println(file1 + " date: " + finalDate1);
        else {
            // File or directory does not exist
            file1_stat = "does not exist";
        boolean file2Exists = (new File(file2)).exists();
        if (file2Exists) {
            // File or directory exists
            file2_stat = "does exist";
            // Get the timestamp from file 2 and format it
            date2 = (new File(file2)).lastModified();
         Date newDate2 = new Date(date2);
         DateFormat df = new SimpleDateFormat();
         finalDate2 = df.format(newDate2);
         //System.out.println(file2 + " date: " + finalDate2);
        else {
            // File or directory does not exist
            file2_stat = "does not exist";
        if ((file1Exists == false) || (file2Exists == false)) {
                System.out.println("aborting program...");
        else { 
           System.out.println("execution continuing...");
           String relation;
           if (date1 == date2)
             relation = "the same age as";
           else if (date1 < date2)
             relation = "older than";
           else
             relation = "newer than";
           System.out.println(file1 + " (" + finalDate1 + ")" + " is " + relation + ' ' + file2 + " (" + finalDate2 + ")");
    }

  • KM API: Need to add LastModified in input parameters

    Hi All,
    I am trying to add LastModified parameter in my input selection. i already have Service area, country, owner and Document Category as my input parameters. Also i need to select Date from calender.
    Thanks
    Sweta

    Hi Again,
    let me clarify more.
    i am using KM reports. for this i have to use LastModified as my input parameter. in my code i have already added LastModified as my input parameter which is selectin date from calender, but i want it to choose date in from-to format i.e it shoud select date range. Also, i need to know how i can filter my data on the basis of LastModified option.
    i need it urgently. Can anyone help me out on this.
    thanks
    Sweta Sharma
    Edited by: Sweta Sharma8 on Apr 29, 2010 11:31 AM

  • File.lastModified() not working in MAC OS

    Hi all,
    Iam trying to get the lastmodified time of a file using this
            File newFile=new File(uploadFilePath); //uploadFilePath has the path of the file.
            String newFile_Name=newFile.getName();
            long lastmodified=newFile.lastModified(); The above is working in windows but not in MAC. in MAC i get the lastmodified time as 0. I
    s there anyother functionality to get this in MAC. or is it the problem with the path?.
    For eg. the uploadFilePath in PC will be like this
    C:\Documents and Settings\Tanuja\Desktop\File\file_management.txt
    where as in MAC file path of a selected file will be like this.
    /Users/Tanuja/Desktop/file_management.txt
    is this path makes difference or iam i going wrong somewhere?
    could not figure out.
    Thanks,
    Thanuja.

    I found where the problem is. Using the file chooser i selected a file and got the file path and my code deals witht the path as below:
    String uploadFilePath=/Users/Tanuja/Desktop/file_management.txt
    File newFile1=new File(uploadFilePath);
    //Check  whether file exists or not
    if(newFile1.exists()==true)
                out.println("exists");
            else
                out.println("does not exists");
    Result: does not exists
    So i tried by passing the absolute path but all in vain. I get the same result.
    Absolute path: C:\Users\Tanuja\Desktop\file_management.txt
    String uploadFilePath=/Users/Tanuja/Desktop/file_management.txt
    File newFile1=new File(uploadFilePath);
    String abslolutePath=newFile1.getAbsolutePath();
    File newFile=new File(abslolutePath);
    if(newFile.exists()==true)
                out.println("exists");
            else
                out.println("does not exists"); why its not detecting the file though the file path it returned is correct?.
    since it is not detecting the file i got the lastmodified as 0.
    iam using commons upload to upload the file. how commons package is able to detect the file and upload. My upload process is success. but before uploading the file i need to validate it by gettting the lastmodified date. Its not working.
    Any suggestions?
    Thanks,
    Thanuja.

  • How to get LastModified time of a file in repository(in weblogic8 and Compa

    hi ,
    my task is that i have to compare modified time of 2 file.one is in file system other is database file . which is most recently updated (which is newer).
    details :
    we have to check that which file is most recently updated .if database 's file is newer then we copy that file in to file system other wise we keep file system 's file as it is till database file is not updated
    so that we can put the latest data in cache(which is in file system ) so we need not to access database again and again we just get data from our cache(or file system).
    technical Detail:
    my task is that i have to compare cache's file and repository's file . which is most recently updated (which is newer).
    in all i have to done in weblogic server 8.2 's repository and file system(cache) .
    i want to know that how we can check that when the file in repository last modified.
    i want to check that node content of a particular repository (file /image/any data ) last modified by anyone , so that i can put the latest data in cache if cache 's file modified time
    is less then repository's file modified .other wise no need to copy all file/data again and again ,if no modification .

    If the file is in the resource path of a webapplication, then you can use
              URL u = servletContext.getResource("path/to/resource");
              URLConnection connection = u.openConnection();
              connection.getLastModified()
              If the webapp is exploded, then you can use the getRealPath() on servletContext to get the absolute path on the disk and create a File, then invoke lastModified() to get its timestamp.
              -- Nagesh

  • Problem with lastModified of a file

    hello eb
    i want to have the date of the last modification of a file for some file i getthe correct answer and for other i have "Thu Jan 01 01:00:00 GMT 1970" i think that it is the bigining of the counting for the date
    but i dont knox why
    if so can help me ill be greate
    this is my code
    File Old = new File("c:\\EspaceCardio\\"+NomCardio+"\\Etudes\\"+NomEtude+"\\"+TypeECG+"\\Fait\\"+Result_Choix[p]);
    //je convertit linstant de la derni�re modification en une date
    Date dateModificationLog = new Date(Old.lastModified());
    String date = dateModificationLog.toString();
    System.out.println("***************");          
    //System.out.println(OldLog.lastModified());  
    System.out.println(dateModificationLog);
         

    i have better situated the problem
    i display the date of last modified in a jtable
    but in the first line of the table the date of the file is correct and in all the other is wrong .
    really i have not understand why
    this my code :
    for(int p=0;p<Result_Choix.length;p++)
    File Old = new File("c:\\EspaceCardio\\"+NomCardio+"\\Etudes\\"+NomEtude+"\\"+TypeECG+"\\Fait\\"+Result_Choix[p]);
    //je convertit linstant de la derni�re modification en une date
    dateModificationLog = new Date(Old.lastModified());
    String date = dateModificationLog.toString();
    System.out.println("***************");          
    //System.out.println(OldLog.lastModified());
    System.out.println(dateModificationLog);
    if(TypeECG.equals("Lecture"))TypeECG="L";
    if(TypeECG.equals("Controle"))TypeECG="C";
    k = k + 1;
    res = Integer.toString(k);
    String[] col1 = {res,NomCardio,NomEtude,Result_Choix[p],TypeECG, date};
    aModel.addRow(col1);
    TableColumn column = null;
    for (int i = 0; i < 6; i++)
    column = Table_Ecg.getColumnModel().getColumn(i);
    if (i == 0)
    column.setPreferredWidth(2);           
    if (i == 1)
    column.setPreferredWidth(40);
    if (i == 2)
    column.setPreferredWidth(40);
    if (i == 3)
    column.setPreferredWidth(130);
    if (i == 4)
    column.setPreferredWidth(8);          
    if (i == 5)
    column.setPreferredWidth(100);
    Table_Ecg.setModel(aModel);

  • Converting time string to millisecs

    Hiya
    I have a string representing time, that i read from a file 06:30:04.271 (hr:min:sec.millisec). What would be the best way to convert this to milliseconds.
    I can also add the date if necessary: 2003-12-31
    I need to manipulate about 20,000 dates :-), so the solution needs to be efficient..
    anyideas would be much appreciated
    thnx heaps
    Osiris

    try
    SimpleDateFormat to make a Date object.
    Then Date.getTime() which will return the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.
    ciao
    jamie

  • Problem with javascript:alert(document.lastModified)

    After I upgraded to Firefox 6.0.1 and now today to 6.0.2, I'm unable to get any response to my using javascript:alert(document.lastModified)
    in order to get a web page date.

    A lot of websites are generated dynamically by a script (e.g. PHP or other server side script) that runs on the server and in that case you will always see the current date.

  • File modification date (lastModified())

    Hi, would like to get the last modification date of a file.
    I'm using lastModified() from class File, but it always gives
    me back the actual date.....I don't understand where's the problem.
    the code is:
    file = new File(excelPath);
    Date fecha = new Date(file.lastModified());
    Thanks.

    file = new File(excelPath);
    Date fecha = new Date(file.lastModified());Are you sure that the file exists? Otherwise, you'd probably see the creation time, which is, guess what, now.

  • How to Get Millisec from Sysdate

    Hello all
    How to get millisec from sysdate.
    Pls let me know da query ..

    You can't get milliseconds from SYSDATE. In 9i and upwards you can get them from a timestamp, whether it be from the built-in functions SYSTIMESTAMP and LOCALTIMESTAMP or a timestamp column/variable of your own.
    Unfortunately, Oracle only supplies the means to extract seconds, but fortunately, this includes the millilseconds, which are easy enough to get to as the following demonstrates:-
    SQL> select extract(second from localtimestamp) from dual;
    EXTRACT(SECONDFROMLOCALTIMESTAMP)
                   42.765535
    SQL> select mod(extract(second from systimestamp),1) from dual;
    MOD(EXTRACT(SECONDFROMSYSTIMESTAMP),1)
                          .181223Regards
    Adrian

  • Document.lastmodified in JSP?

    I am trying to implement the JavaScript document.lastmodified function in a JSP, but the date does not generate on my HTML page (no errors occur, date does not dispplay). Using document.lastmodified works fine if it's plugged right into the HTML page, so I am not sure why it does not work from within the JSP. If anyone has any ideas and/or an example I can try, I would appreciate it. Thank you.
    Paul

    there is a standard one:
    HttpServlet.getLastModified() Why reinvent a wheel?
    Paul

  • Java Time in millisec

    Hi,
    This should be a simple thing to do in java but i have spent a lot of time without getting the desired result. I have a time in YYYY:MM:DD:hh:mm:ss format and I want to find the number of millisec since Jan 1 1970 (UTC time). I have tried to use the Calender class but its not giving the correct output
    Calendar c = Calendar.getInstance();
    c.set(2006, 6, 8, 10, 55, 00); // Today 10:55 am
    System.out.println("Time is "+c.getTimeInMillis());
    Can anyone help me with this.
    Thanks.

    Ok that was a dumb question. I should have figured
    that out myself.
    SimpleDateFormat simpledateformat = new
    SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
    System.out.println("SimpleDateFormat time is
    "+simpledateformat.parse("2006-06-08-07-20-00").getTim
    e());
    Another Question: Will Date now = new Date(); take
    care of daylight saving? What I am doing is
    SimpleDateFormat formatter = new SimpleDateFormat(
    "yyyyMMdd:HH:mm:ss");
    formatter.setTimeZone( TimeZone.getTimeZone("GMT")
    Date now = new Date();
    formatter.format(now);
    So will it automatically adjust with daylight
    saving?GMT doesn't have DST.

  • Prompt i want to display as From Date & To Date - as a lastmodified date

    Hi All,
    i want to displayed as a from date and to date from the column name as lastmodified date in the prompt. in the prompt i selected the between option it is displayed as a between and not as a from date - to date.
    From Date(prompt button as calender)----------To Date
    Thanks
    Chandra

    Hi,
    can u pls look into the below link
    http://docs.oracle.com/cd/E10415_01/doc/bi.1013/e12188/T421739T524310.htm

  • Possible Bug on File.lastModified() [Java 1.5]

    The method long lastModified() of class File is bugged, it returns a wrong time, the hours are increased by one

    Are you sure it is not a time-zone issue?

Maybe you are looking for

  • Tables or FM for list of reports

    Hi ABAP gurus,   Please help me with the below requirements 1) Have to display list of all standard reports availabe in SAP HR module as a report 2) User specfic data on the HR reports like how many times a particular user has executed a report in a

  • Can't access the Online Player, nobody can help

    I am at my wit's end. I am an Infinity customer, and all I want is access to the BT Sport Online Player.  This seems to baffle absolutely everybody at BT. I can't activate the player online, since it constantly gives me an error. Why you need everyon

  • I need help asap. Does anyone know how to recover iMovie project that just disappeared?

    I went to hit play on my iMovie project, which is finished and had been playing great. this time I hit play and the screen goes black and now it appears the project is gone. The title is still under the folders section, but no clips in there. I've lo

  • How to get rid of mail number on e-mail icon?

    How do I get rid of the red mail count number from e-mail icon?

  • Keeping styles when converting html to PDF

    Acrobat Professional 8.1.2, Word 11.42, PowerPC G5 Dual 2.7GHz 1.5Gb Ram, OS 10.4.11 I have been trying to save a word file to PDF with links that have been copied from my website. Creating a PDF from word doesn't keep the links, to get around this I