Unix timestamp with jsp

hi all,
i need to convert current time to unix timestamp. actaully i'm a PHP programmer but i plan to use jsp in the future. when i write web applications with PHP, i use mktime() function which converts any given time to unix timestamp value. so i store returned integer value to database as an integer field. this helps me when i need to compare dates with sql commands. and when i need to reconvert this integer to date value i use anoher php function date().
so my question is, how can i do such a thing with java? people talk about a class java.sql.Timestamp, is it the timestamp that i look for?
any helps (especially code samples) will be useful...

ok i found out how to get the time in miliseconds. by getTime() method of Date class. but i still have problems. if u interested this topic is moved to java programming forum under title "date in miliseconds".

Similar Messages

  • Unix Timestamp & Formula

    Post Author: eskimo42
    CA Forum: Formula
    I have an ecommerce DB which I am trying to report on using Crystal
    Reports 2008. Please bear with me, this is my first time using Crystal
    Reports. Here is my issue: The
    order creation date field in the eCommerce DB is being pulled as a Unix
    Timestamp. After some research online I have found that this formula
    should help me convert the timestamps into a readable format:DateAdd (u201Dsu201D,{jos_vm_orders1.cdate}-18000, #1/1/1970#)So
    I have created numerous formula fields, Formatting Formulas, Custom
    Functions, and all I can seem to come up with is this error:The ) is missing. I
    really hope someone can walk me through how exactly I can convert a DB
    field which appears in a report to, a readable time stamp with that
    formula I have above. Thanks,Evan

    Post Author: bettername
    CA Forum: Formula
    Glad that worked!
    Since Crystal doesn't support UnixTimeStamp<->DateTime conversion (c'mon guys!), you're going to have to write a formula for each field that you want to display that uses a Timestamp field (boring, yes!), and drag each of the formulas onto the page.  I sure hope I'm missing something there...
    You could create a custom function to save some typing - have a look at http://publib.boulder.ibm.com/infocenter/radhelp/v6r0m1/index.jsp?topic=/com.businessobjects.integration.eclipse.doc.crdesigner/reportdesigner/crconcustomfunctions.htm, but essentially the code is:
    Function (numbervar UnixTimeStamp)DateAdd ("s",UnixTimeStamp-18000, date(1970,01,01))
    That way, each time you want to convert a field, you just type a formula that says "UnixToDateTime ({yourTable.YourField})"
    I think you know where to create a formula (View - Field Explorer).  Once you've created the formula, drop it in the details section, then goto 'Insert' - 'Group', choose the formula and the rest should be obvious...

  • How can i convert the firefox-history-timestamp in places.sqlite into a normal date format? The firefox-timestamp is not equivalent to the unix-timestamp, that's why I ask. I could not find a conversion function. Does anyone know something about this?

    As I opened the places.sqlite with an sqlite-editor I found out that firefox saves the last_visit_date via a timestamp which is 16 digits long. I realized that the first 10 digits are similar to the corresponding unix-timestamp but not equal. So.. how can i convert the firefox-timestamp into a normal date? Or into the corresponding unix-timestamp?

    Write a bash script or 'C' program to change the date format and then use the sql update function to receive the stdio output 'where date_field='embeded date value'.

  • Convert UNIX timestamp in a report in Report Builder

    Hi,
    I have a column with unix timestamp (i.e 1386782654 ).
    How can I make that conversion to a dateformat  like 2013-03-05 17:32 ?
    I have tried =DateAdd("s", Fields!timestamp.Value, "19700101 00:00:00:000") but it just gives me an error.
    Anyone knows how to get this right?

    I solved it myself,
    The correct expression is: =DateAdd("s", Fields!timestamp.Value,"1970-01-01 00:00:00")

  • Unix timestamp conversion to human readable representation ...

    Hi,
    I map unix timestamps from MaxDB to the controller context of Web Dynpro and display the results in a table. Is there a smart way to convert the timestamps to human readable date and time? Maybe some way to manipulate the table values with a function before they are written ..?
    For now, I create a new node in the context and manually set each value with the according date/time representation ... but thats pretty cumbersome.
    Thank you very much for your help!
    Cheers,
    boris

    Hi Boris,
    Check http://java.sun.com/j2se/1.3/docs/api/java/text/SimpleDateFormat.html
    Date currentTime_1 = new Date(longUnixTimestamp);
    String dateString = formatter.format(currentTime_1);
    I would suggest you to create a calculated attribute under the same node as initial timestamp value and return a result of SimpleDateFormat.format().
    Best regards, Maksim Rashchynski.

  • Getting a date as a unix timestamp

    Hello everyone,
    is the long that is returned by the getTime() method in the date class supposed to be the same as a unix timestamp?
    Below I have a time from yesterday, but when i compare this with System.currentTimeMillis(), the currentTime has a smaller timestamp
    code]SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy-kk:mm:ss");
              long expiryDate=0;
              try{
                   Date d = sdf.parse("11-11-2006-19:07:50");
                   expiryDate = d.getTime(); results in 1163358470000
              catch(ParseException pe){
                   pe.printStackTrace();
    yesterdays time is 1163358470000
    current time is 1163355193562 // smaller number
    Whats going on?

    sorry, here it is again
    is the long that is returned by the getTime() method in the date class supposed to be the same as a unix timestamp?
    Below I have a time from yesterday, but when i compare this with System.currentTimeMillis(), the currentTime has a smaller timestamp
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy-kk:mm:ss");
    long expiryDate=0;
    try{
    Date d = sdf.parse("11-11-2006-19:07:50");
    expiryDate = d.getTime(); results in 1163358470000
    catch(ParseException pe){
    pe.printStackTrace();
    }yesterdays time is 1163358470000
    current time is 1163355193562 // smaller number
    Whats going on?

  • Select entries between two dates by converting Unix timestamp in Oracle Dat

    Hi,
    I need to select the entries between two dates from an Oracle db. The Oracle db has a column with Unix timestamps. I use the following querry, but it doesnt seem to be working as desired.
    select count(*) from reporter_status where to_char(FIRSTOCCURRENCE, 'mm-dd-yy') between ('08-07-06') and ('08-08-06');
    FIRSTOCCURRENCE has the Unix timestamps.
    Could anyone help me out with this. Thank you for your help.

    Assuming that it is actually a UNIX timestamp, then it is the number of seconds since Jan 1, 1970, so you need something like:
    SELECT COUNT(*)
    FROM reporter_status
    WHERE TO_DATE('01-Jan-1970', 'dd-mon-yyyy') + (firstoccurrence/24/60/60)
                    BETWEEN TO_DATE('08-07-2006', 'mm-dd-yyyy') AND
                            TO_DATE('08-08-2006, 'mm-dd-yyyy');Did Y2K not teach us anything? Use 4 digit years.
    John

  • Unix timestamp / epoch conversion in IQ

    Hello,
    I searched the community as well as some other historical locations, but couldn't find any discussions on this.
    In several of the projects I am working with, there is a source datetime field that always comes in as a unix timestamp (i.e. seconds since the epoch). The question I regularly get is, can we load this into IQ and have it converted during load from the integer into an IQ datetime column.
    I have my own suggestions for how to solve this already, but rather than influence the creative (or resolute) mind, I thought I'd put it out to the community to see how you have/would solve this issue?
    Thoughts??
    Thank you,
    -Joe Love
    SAP Mobile Services and Consumer Insights

    None that I am aware of during the LOAD TABLE event.  You can always load it and post process the data, but that's gets ugly and requires you to carry an extra column in your table.  My typical approach is to have the data converted before loading into IQ.  If the data is being touched by a streaming engine, ETL tool, or replication, you can do it all inline with those tools and a little coding.  For 3rd party tools, I would have them change their code to generate readable date/time stamps.  That or pre-process the data with something like sed or awk.
    Mark

  • Problems with JSP in Firefox

    I have seen several references to this problem on this forum but no real solution on any of the pages I have found. My jsp, which right now is no more than a static HTML page with jsp as the extension so that I can add the java code later, will not display in firefox it only shows the source code when I go to my website. Some example code is below.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
         <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
         <title>
              Sichutech.com
         </title>
         <link rel="stylesheet" href="theme/NewMaster.css" type="text/css">
    </head>
    <body>
              <div class="spacer"> </div>
              <div id="banner" align="left">
                    <img src="images/logocropped.png">
              </div>
                        <br class="clearboth">
                        <div class="spacer"> </div>
                        <div id="row1col1" align="left">
                   <img src="images/home.png"><br>
                   <img src="images/mission.png"><br>
                   <img src="images/about.png"><br>
                   <img src="images/services.png"><br>
                   <img src="images/contactus.png">
              </div>
              <div id="row1col2" align="left">
                   <img src="images/worldwide.png"><br><br>
                   <p>
                        <b>Stand alone application development:</b><br><br>
                        We provide stand-alone application development for businesses of any size.
                        Our applications are developed in Java using best standards and practices.
                   </p>
                   <p>
                        <b>Web Development:</b><br><br>
                        We provide custom web development for businesses of any size. We use J2EE
                        technologies to develope all web applications. These technologies consist
                        of Java, Javascript, Java Beans, HTML, JSP, XML, and other technologies as
                        applicable.
                   </p>
                   <p>
                        <b>Questions:</b><br><br>
                        For a quote on a custom stand-alone or web application to meet your business
                        needs please contact us through the contact us page.
                   </p>
              </div>
              <br class="clearboth">
              <div class="spacer"> </div>
              <div id="footer">
                   Home 
                   Mission
                   About Us
                   Services
                   Contact Us
                   &#149;
                   Copyright &copy; Sichutech 2008 All Rights Reserved
              </div>
              <br class="clearboth">
         </body>
    </html>
    The website is up and running and displays fine in IE but not firefox. The site address is www.sichutech.com
    Any help is greatly appreciated.
    Thanks,
    Robert

    Here is what I see at the response headers:
    Date: Wed, 06 Aug 2008 02:37:52 GMT
    Server: Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.8b DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 mod_jk/1.2.25 mod_perl/2.0.4 Perl/v5.8.8
    Last-Modified: Mon, 04 Aug 2008 22:42:24 GMT
    Etag: "aa0088-602-453aa0d911400"
    Accept-Ranges: bytes
    Content-Length: 1538
    Content-Type: text/plain
    X-Antivirus: avast! 4
    X-Antivirus-Status: Clean
    200 OKNote the content type: it is text/plain instead of text/html. And FireFox interpreted it correctly as text/plain.

  • Unix timestamp in cfgrid

    Sometime ago I produced a php and SQL jobsite. Users apply
    for jobs and the date they apply is converted into a unix timestamp
    and inserted into the SQL as an integer.
    I am now using coldfusion increasingly more, and am wanting
    to display the results above using a cfgrid.
    Although I have found similar posts in this forum I still
    have two oustanding queries:
    1) How do I catch the date for each row before the cfgrid
    displays it
    2) How to convert unix timestamp using coldfusion

    chilliroom wrote:
    >
    quote:
    format it via the db is probably the cheapest.
    > I am still unsure how to catch the date for each row
    before the cfgrd grabs it.
    what db? does it have this functionality? for sql server
    something like should
    work (but again watch for overflow):
    SELECT
    dateAdd(second,yourUnixEpochOffsetDataColumn,'1-jan-1970') as
    aDate,....
    FROM yourTable
    > How can I extract this value to then feed into
    "yourUnixEpochOffsetData".
    if your db can't handle this, here's one way using cf (but
    the db is cheaper).
    do your normal cfquery then:
    - convert the unix epoch offsets to datetimes:
    unixEpoch=createDate(1970,1,1);
    newDates=arrayNew(1);
    for (i=1; i LTE yourRegularcfQuery.recordCount;i=i+1) {
    newDates
    =dateAdd("s",yourRegularcfQuery.yourUnixEpochOffsetDataColumn,unixEpoch);
    depending on your needs, you might also want to dateFormat
    the results of the
    dataAdd:
    newDates
    =dateFormat(dateAdd("s",yourRegularcfQuery.yourUnixEpochOffsetDataColumn,unixEpoch));
    - add a column to your cfquery & fill with those
    converted dates,
    queryAddColumn(yourRegularcfQuery,"aDate","date",newDates);

  • Oracle timestamp to unix timestamp

    Hi everyone!
    I need to convert a values fetched from a db table in a unix timestamp (seconds passed by january first 1970).
    The table is like this
    create table test(.... ts timestamp not null...);
    and the code to define the output variable (for a select statement) is the following, where time is an OCIDateTime variable
    OCIDefineByPos(stmth, &defineh, errh, pos, (dvoid *) time, 0, SQLT_ODT,
    (dvoid *) 0, (ub2 *) 0, (ub2 *) 0, OCI_DEFAULT);
    once I have initialized "time", how can I convert his content to unix timestamp?
    And viceversa, how can I put an int value rapresenting a unix timestamp in an OCIDateTime variable, and then insert it correctly inside mt table?
    thank you!
    GePs

    I define my buffer according on the the table's field width I retrieve from metadata. In ths way:
    OCIAttrGet((dvoid *) pars, (ub4) OCI_DTYPE_PARAM, (dvoid *) col_width, (ub4 *) 0,
    (ub4) OCI_ATTR_DATA_SIZE, (OCIError *) err);
    Now in col_width there's the dimension of the field (for a timestamp field is 11!). Then I bind the correct variable in the correct manner (with a varchar2 fiedl it works!)
    int pos = 1;
    char *time;
    time = malloc(sizeof(char*));
    OCIDefineByPos(stmt, defs, err, (ub4) pos, time, (sword) col_width+ 1, SQLT_STR, (dvoid *) 0,
                                  (ub2 *)0, (ub2 *)0, OCI_DEFAULT);
    Now if I print time I get the trunked timestamp
    printf("%s", time); //-> 11-NOV-05 1

  • How to get Unix timestamp?

    Hi All,
    Didn't find any solution with a search so asking if somebody's already implemented a method to get a Unix timestamp in BPEL? It's a number of seconds since Jan-1-1970. I'm quite new to BPEL so any help is appreciated!
    Thank you in advance,
    Philipp

    Hi Philipp,
         One approach can be to use Java embedding in BPEL to get Unix timestamp.
    Check this out Java Embedding Activity in BPEL | Oracle SOA Training | BPEL, OSB, BAM, OWSM, B2B |ORACLE FUSION MIDDLEWARE SCHOOL
    Ref: Incorporating Java and Java EE Code in a BPEL Process
    -- Sid

  • Convert Unix timestamp to LabVIEW time

    Hello
    I need to convert a Unix timestamp comming froma dll to a LabVIEW time. Does anybody now some ready to use function for this?
    Thanks
    Solved!
    Go to Solution.

    DAckermann wrote:
    Oh yes. That was easy.
    Thank you very much!
    Exceot that there is a small possible gotcha. If you enter 1/1/1970 in a LabVIEW timestamp control and convert this to a double to get the number of seconds you likely end up with an error of your local timezone offset.
    Both the Unix and LabVIEW epoch are defined respective to GMT which for most practical purposes is the same as UTC. So you have to make sure to get the number of seconds for a timestamp that shows 1/1/1970 00:00 UTC to be right.
    Spoiler (Highlight to read)
    If you ended up with 2082844800 as offset then you got it right.
    If you ended up with 2082844800 as offset then you got it right.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • SQL query with JSP and WML-parameters

    Hey,
    Could you help me?
    I'm trying to do the following. WML deck card 1 send parameter to same WML deck's card help. I try to read the parameter with JSP in card help by putting the parameter to SQL query, but it doesn't work. I can read the parameter with WML in card help. I can also print the value of the parameter with JSP if I generate WML with JSP.
    /*parameter sending from card 1 to card help*/
    out.println("<go href='#helpcard'>");
    out.println("<setvar name='valittukurssi' value='$(valittukurssi)'/>");
    /*parameter read with WML in card help */
    <p>Valitse kurssi.
    $valittukurssi</p>
    /'parameter read with JSP by generating WML with JSP*/
    out.println("<p>$valittukurssi</p>");
    /* SQL query with JSP */
    ResultSet uudettulokset = uusilause.executeQuery("select * from kurssi where lyhenne='$valittukurssi'");
    Thanks,
    Rampe

    You're problem is easy to fix. You're confusing WML variables with JSP variables. See below:
    >
    /*parameter sending from card 1 to card help*/
    out.println("<go href='#helpcard'>");
    out.println("<setvar name='valittukurssi'
    value='$(valittukurssi)'/>");
    Above you set a var that will work on the phone, not in JSP.
    /*parameter read with WML in card help */
    <p>Valitse kurssi.
    $valittukurssi</p>
    Yes the above does display the parameter, because it is a client side WML var, but you cannot use this variable in the JSP code (that's why your SWL fails).
    /'parameter read with JSP by generating WML with
    JSP*/
    out.println("<p>$valittukurssi</p>");Here's you're problem, the above line is EXACTLY the same as the one before it. When the container parses through this JSP code it translates the above line to:
    <p>$valittukurssi</p> on the WML page and the CLIENT uses it's local variable to display it.
    What you need and want is to have a variable that can be used in JSP code and output to your WML page. Here's how it's done:
    out.println("<go href='#helpcard'>");
    String some_name = "valittukurssi";
    out.println("<setvar name='"+some_name+"'
    value='$("+some_name+")'/>");
    //note that you may have to escape the ( and ) with a \
    //so we displayed the variable above into the WML page, now we can use it in the SQL query:
    /* SQL query with JSP */
    ResultSet uudettulokset =
    uusilause.executeQuery("select * from kurssi where
    lyhenne='"+some_name+"'");//the end of the command is: " ' " ) ;
    Frank Krul
    Got Node?

  • Create a new directory in server with JSP

    Hi,
    How can I create a directory in server with JSP.
    File dir = new File("a");
    dir.mkdir();
    does not work. what do I do?
    best regards,

    Hi
    Check the following things.
    1. What is the path where you are creating the directory.
    2. Do you permissions to create file in that directory.
    3. do a delete on that filename if that exists just to be sure. isdeleted = filedir.delete(). Check the boolean flag isdeleted too.
    Thanx and Regards
    Aruneesh

Maybe you are looking for

  • Am unable to log in to Verizon email with Firfox. I get "Unsupported Method". I am able to log in using Internet Explorer.

    Firefox will not accept my log in and password on this computer. Sometimes it will log in, but I can't predict when it will. I can log in from other computers in Firefox. Can log in on this one using only IE. My wife can log in using Firefox.

  • Missing iPhoto thumbnails

    I've tried everything, but just can't seem to get iphoto to display large or small thumbnails.  Exported iPhoto library to external hard disk a couple of months ago and all continued to work well.  Then updated to snow Leopard OS.  A week later noted

  • Plug in pdf sous android

    Comment faire pour lire un pdf sans objet application/pdf sous android ? J'ai à l'écran "google chrome n'est pas compatible avec ce plug in"

  • Window form Sapscript

    Hi, i need to draw a window like the following is it possible: TEXT  ****************** TEXT  ****************** is it possible to draw a simple line? thx, Regards Soufiane.

  • SpeedGrade update error U44M11210

    Dear All, I have received many Adobe updates recently and all have installed except SpeedGrade which gives me the error message U44M11210.  I have tried this install many times to no avail.  What does the error message U44M11210 refer to? I'm working