cancel
Showing results for 
Search instead for 
Did you mean: 

Display time in webdynpro java

Former Member
0 Kudos

Hi All,

I have a requirement where i have to display server time in webdynpro java can anyone tell me how to do that.

Thanks,

Rahul.

Accepted Solutions (1)

Accepted Solutions (1)

pankaj001
Participant
0 Kudos

Hi Rahul,

Please use this


Date date = new Date(System.currentTimeMillis());

Format format = new SimpleDateFormat("yyyy MM dd HH:mm:ss");

wdComponentAPI.getMessageManager().reportSuccess("Time ::"+ format.format(date).toString());

I think this might solve your query.

Rgds,

Pankaj

Former Member
0 Kudos

Hi Pankaj,

Thanks for your reply using above code i am getting time but it should also show seconds ticking can you tell me how to do this.

Thanks,

Rahul.

pankaj001
Participant
0 Kudos

Hi Rahul,

For that you need to write javascript. But WD doesnt support javascript, so you have to create a BSP application and write the Java script in the BSP page.

In WD add UI element iFrame and give the url of your BSP app as the "source" property of iFrame.

Javascript code for clock :

<html>

    <head>

        <SCRIPT LANGUAGE="JavaScript">

            function MakeArrayday(size) {

                this.length = size;

                for(var i = 1; i <= size; i++) {

                this[i] = "";

                }

                return this;

            }

            function MakeArraymonth(size) {

                this.length = size;

                for(var i = 1; i <= size; i++) {

                this[i] = "";

                }

                return this;

            }

            function funClock() {

                if (!document.layers && !document.all)

                return;

                var runTime = new Date();

                var hours = runTime.getHours();

                var minutes = runTime.getMinutes();

                var seconds = runTime.getSeconds();

                var dn = "AM";

                if (hours >= 12) {

                dn = "PM";

                hours = hours - 12;

                }

                if (hours == 0) {

                hours = 12;

                }

                if (minutes <= 9) {

                minutes = "0" + minutes;

                }

                if (seconds <= 9) {

                seconds = "0" + seconds;

                }

                movingtime = "<b>"+ hours + ":" + minutes + ":" + seconds + " " + dn + "</b>";

                if (document.layers) {

                document.layers.clock.document.write(movingtime);

                document.layers.clock.document.close();

                }

                else if (document.all) {

                clock.innerHTML = movingtime;

                }

                setTimeout("funClock()", 10)

            }

            window.onload = funClock;

        </script>

    </head>

    <body>

        <center> Currently, it's <span id=clock></span> </center>

            <form action="Clock.html" method="get">

            </form>

    </body>

</html>

Let me know if this works for you.

Rgds,

Pankaj

Answers (0)