How to get Date and time of the server?

Hi, How can we get the date and time of the server while submitting a form using JSP? i.e I need the date and time , when the user is submittig a registration.
Uma

Upon receiving your data in your servlet, you can do the following to get the date,
Calendar calendar = Calendar.getInstance();
int dd = calendar.get(Calendar.DAY_OF_MONTH);
int mm = calendar.get(Calendar.MONTH) + 1;
int yyyy = calendar.get(Calendar.YEAR);
String dd_mm_yyyy = dd + "/" + mm + "/" + yyyy;
To get the time, simply take a look at the Calendar API to get the corresponding field.

Similar Messages

  • How to get date and time? pls help~   ~.~

    i tried to get time and date, but dint noe hw to get it.. anyone knows hw to get it? pls help mi ~.~
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.Calendar.*;
    public class Login extends JFrame
    private JFrame mainFrame;
    private JPanel p1;
    private JLabel lblUserId, lblPassword;
    private JTextField tf1, tf2;
    private JButton btnLogin, btnClear;
    public Login()
         mainFrame=new JFrame();
         mainFrame.setTitle("Student Attendance System");
         mainFrame.setSize(400,200);
         mainFrame.setLocation(100,100);
         mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         p1=new JPanel();
         p1.setLayout(new GridLayout(3,2));
         lblUserId=new JLabel("User ID");
         lblPassword=new JLabel("Password");
         tf1=new JTextField(20);
         tf2=new JTextField(20);
         btnLogin=new JButton("Login");
         btnLogin.addActionListener(new ButtonHandler());
         btnClear=new JButton("Clear");
         btnClear.addActionListener(new ButtonHandler());
         p1.add(lblUserId);
         p1.add(tf1);
         p1.add(lblPassword);
         p1.add(tf2);
         p1.add(btnLogin);
         p1.add(btnClear);
         mainFrame.add(p1);
    mainFrame.setVisible(true);
    //inner class event handler
    public class ButtonHandler implements ActionListener
         public void actionPerformed(ActionEvent evt)
              Calendar rightNow = Calendar.getInstance();
              if(evt.getSource()==btnLogin)
                   String login=tf1.getText();
                   String password=tf2.getText();
                   JOptionPane.showMessageDialog(mainFrame, "Student ID "+login+" Login at " + rightNow ,
                   "Response", JOptionPane.PLAIN_MESSAGE);
              if(evt.getSource()==btnClear)
                   tf1.setText("");
                   tf2.setText("");
    public static void main(String []args)
         JFrame.setDefaultLookAndFeelDecorated(true);
         Login l=new Login();
    }

    First off, from http://www.catb.org/~esr/faqs/smart-questions.html
    h1. How To Ask Questions The Smart Way:
    h3. Write in clear, grammatical, correctly-spelled language
    More generally, if you write like a semi-literate boob you will very likely be ignored. So don't use instant-messaging
    shortcuts. Spelling "you" as "u" makes you look like a semi-literate boob to save two entire keystrokes. Worse: writing like
    a l33t script kiddie hax0r is the absolute kiss of death and guarantees you will receive nothing but stony silence (or, at best,
    a heaping helping of scorn and sarcasm) in return.
    Next, use a SimpleDateFormat object. You can use it directly or use a date format string to tell it how you want your date string formatted. The API will give you lots of information on how to use this. Note that you'll have to translate the Calendar object to a date object via the getTime() method:
        class ButtonHandler implements ActionListener
            public void actionPerformed(ActionEvent evt)
                Calendar rightNow = Calendar.getInstance();
                //** use SimpleDateFormat
                SimpleDateFormat dateFormat = new SimpleDateFormat();
                String dateString = dateFormat.format(rightNow.getTime());
                if (evt.getSource() == btnLogin)
                    String login = tf1.getText();
                    String password = tf2.getText();
                    JOptionPane.showMessageDialog(mainFrame, "Student ID " + login
                            + " Login at " + dateString,
                            "Response",
                            JOptionPane.PLAIN_MESSAGE);
                if (evt.getSource() == btnClear)
                    tf1.setText("");
                    tf2.setText("");
        }Finally, when posting your code, please use code tags so that your code will retain its formatting and be readable. To do this, either use the "code" button at the top of the forum Message editor or place the tag [code] at the top of your block of code and the tag [/code] at the bottom, like so:
    [code]
      // your code block goes here.
    [/code]

  • How to get the current data and time of SCOM server via SCOM SDK (API) calls?

    Hi,
    I need to read the current date and time of SCOM server via SOM SDK.
    Is there a class in SDK that provides this info ?
    Thanks,
    satheesh

    To get time and date of Alerts of SCOM, You can use following command let "get-scomalert"
    Also, You can refer below links
    http://blog.tyang.org/2013/02/21/using-scom-2012-sdk-to-retrieve-resource-pools-information/
    Please remember, if you see a post that helped you please click "Vote As Helpful" and if it answered your question, please click "Mark As Answer"
    Mai Ali | My blog: Technical

  • Getting Date and Time to Show in the Menu Bar

    I have the OS setup to set the date and time automatically and the clock set to "show date and time in the Menu Bar. I have the international set up for the Day of Week, Month, Date and Year, but the menu bar only shows "Fri X:XX:XX PM" is there any way to get it to show me Fri May XX, 2008 X:XX:XX PM"?
    Thanks for any help.
    John

    I use iClock too. It is much more customizable than the Time & Date clock provided with the system. I have used it for several years and it has been very stable for a third-party application.
    Although I have only used it for a couple of months, I also really like another third-party application you may like, to put weather conditions on the menubar called WeatherDock (freeware). It accesses Weather.com to provide the current temperature (of course) but it can include several other weather conditions (depending on how much space you have on your menubar). In addition to temperature, I have it show the weather condition (currently partly cloudy, typical in Houston), wind direction and speed (I ride a bike to the office and this tells me if I’ll be fighting it or aided), and humidity (also a Houston favorite). It will also speak the weather conditions when they change.

  • I need to get the Current System Date and time in the format

    I need to get the Current System Date and time in the format
    *6/24/2009 11:30:29 AM*
    How do i do it ?

    I seem to be saying this a lot lately.
    Google is your friend.
    I googled "java current date format" and SimpleDateFormat featured prominently in the results.

  • How change sStart and End Date and time in the Audit log ???

    Install C2S BM39SP1. Work.
    Go to the: https://bmserver:8009
    Open : VPN Monitor | Audit log information.
    Problem - can not cahnge Date and time in the Audit Log Start(End)
    How i vcan do this ?
    How i can get every day stat log:
    login ; date_time_login ; dtae_timie_logout ; bite_in ; bite_out
    Serg

    Serg,
    It appears that in the past few days you have not received a response to your
    posting. That concerns us, and has triggered this automated reply.
    Has your problem been resolved? If not, you might try one of the following options:
    - Visit http://support.novell.com and search the knowledgebase and/or check all
    the other self support options and support programs available.
    - You could also try posting your message again. Make sure it is posted in the
    correct newsgroup. (http://support.novell.com/forums)
    Be sure to read the forum FAQ about what to expect in the way of responses:
    http://support.novell.com/forums/faq_general.html
    If this is a reply to a duplicate posting, please ignore and accept our apologies
    and rest assured we will issue a stern reprimand to our posting bot.
    Good luck!
    Your Novell Product Support Forums Team
    http://support.novell.com/forums/

  • Get date AND time to show in the menu bar

    What is that technique to get date AND time to show in the menu bar please?

    Install iStat Menu
    System Preferences -> iStat Menus -> Date & Time
    \[X] Show Date & Time
    Format .... \[Edit]
    (*) Custom (drag tokens to build a custom format)
    Drag a light blue token into the edit line below the token selections. If you want a space a colon a dash, etc... just type that character(s) before after draging a token into place.
    I created: 9:35 PM Sat 1-Aug-2009
    You can create anything you like in any order you like.
    The other alternative (if you happen to be a fan of the Unix strftime() function) would be to use the % formatting characters in the Expert time format expression box. Use the Terminal "man strftime" to find out all the available % formatting codes.
    But I think the Custom Drag & Drop section is the easiest to use.
    However, if this doesn't work for you, then I guess it is just a case of "Your Mileage May Vary".

  • How do I add the capture date and time to the bottom corner of a photo?

    How do I add the capture date and time to the bottom corner of a photo?

    Not to the bottom, that I'm aware of, but to the top right or left in Grid view or to the top left in Loupe view. It is in the View Options.

  • How do I get date and time component from a DATE object?

    Hi All,
    I need to get date and time separately from a DATE object, does
    anyone know what function I should call? GetDate()? GetTime()?
    I need this in a SELECT statement.
    Thanks in advance and looking forward to your early reply.
    Regards.
    Gladywin
    30/11/2001

    Hello,
    See following SQL.
    select to_char(sysdate,'dd/mm/rrrr') today_date,
    to_char(sysdate,'hh24:mi') now_time
    from dual
    Adi

  • TO_DATE - How do I pass the date and time to the function

    Hi,
    I am writing a PL/SQL code. The code has a simple cursor,
    For the criteria, I am using a column called 'created' which is a date column, and the to_date function.
    I would like to pass the date and time to the to_date fuction as a parameter, date_value, as shown below.
    CURSOR opty is
    select a.name, a.id
    from s_opty a
    where a.created > to_date(date_value, 'DD/MM/YYYY HH24:MI:SS');
    I've tried declaring a bind variable,
    date_value date := '&1'
    but no joy.
    Any ideas would be welcomed.
    Thanks in antcipation
    Mukesh

    Can this help you?
    SQL> create or replace procedure sample_proc
      2  as
      3  cursor c1(v_value varchar2) is
      4          select 'YES' from dual
      5            where trunc(sysdate) = trunc(to_date(v_value, 'DD/MM/YYYY HH24:MI:SS'));
      6  v_char varchar2(10);
      7  begin
      8     open c1('08/03/2006 11:35:20');
      9     fetch C1 into v_char;
    10     dbms_output.put_line('Is it today''s date?> '||v_char);
    11     close c1;
    12  end;
    13  /
    Procedure created.
    SQL> begin
      2    sample_proc;
      3  end;
      4  /
    Is it today's date?> YES
    PL/SQL procedure successfully completed.
    SQL> If you are not very particular about the time, you can use TRUNC on both sides like :
    where trunc(a.created) > trunc(to_date(date_value, 'DD/MM/YYYY HH24:MI:SS'));Cheers
    Sarma.

  • How to find date and time on photo taken by iphone?, How to find date and time on photo taken by iphone?

    How to find date and time on iphone's photo taken?

    in iPhoto no matter the source of the photo you see the information about th ephoto by selecting the photo and showing info (the get info button may be in a different location depending on the version of iPhoto you have)
    If you are not aking an iPhoto question but are asking an iPhone question instead then repost in the iPhone forum - iPhoto has no association with the iPhone
    LN

  • How Adobe gets DATE and its format?

    Hello,
    I am getting current (todays) date by using below JS in some flds, and by using below FormCalc for some flds into my_form,
    JS:
    var currentTime = new Date()
    Form Calc:
    $.rawValue = num2date(date(), DateFmt(MM/DD/YYYY))
    But, i dont have much idea that how adobe is getting this date? For my company this is the very first form, hence they are asking me how adobe gets date and its format whether,
    1) From local IP/Interner provider address's date, format?
    2) or user PC/laptop's LOCAL settings date, format? if so, for example, if Germany user (Laptop settings) has a DD.MM.YYYY configured, if this user comes to US on a busines trip and if that user opens the form, then how the date looks like for this user? as per user laptop settings DD.MM.YYYY or local internat provider date format MM//DD//YYYY?
    Thank you

    Hi,
    the date() function returns the number of days since 01.01.1900 for the local date of the current system (related to the system clock of the OS).
    If you travel from Germany to the US but don't update your date/time settings, then it returns the same date in the US as in Germany.
    You can check the behavior by changing your local date/time setting or the timezones.

  • 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 to compare date and time together

    Hi,
    How to compare Date and Time together?
    For example in a database table there are two fields rundate and runtime.  I want to compare these two with perticular date and time in the program.  Like, I want to pull all the records where the records's date and time are less than a perticular date and time in the program.
    Hope the question is clear...
    Thanks.
    Kavita

    Hi Kavita
    There is no as such Date and Time Comparision FM in Standard SAP  But You can define your own like this
    <b>FUNCTION ZAV4_COMPAREDATETIME.
    ""Lokale Schnittstelle:
    *"  IMPORTING
    *"     REFERENCE(DATE1) TYPE  DATS
    *"     REFERENCE(TIME1) TYPE  TIMS
    *"     REFERENCE(DATE2) TYPE  DATS
    *"     REFERENCE(TIME2) TYPE  TIMS
    *"  EXPORTING
    *"     VALUE(TWOISMORETOPICAL) TYPE  C
      twoismoretopical = ''.
      if date2 > date1.
        twoismoretopical = 'X'.
      else.
         if date2 = date1 and time2 > time1.
           twoismoretopical = 'X'.
         endif.
      endif.
    ENDFUNCTION.</b>
    Regards
    Mithlesh

  • HOW: File handling - Date and time of file created/modified

    Hi all,
    Is there any way by which we can find out the date and time of the file created in operating system using file handling through PL/SQL.
    Eg:-
    I have a directory in which I am storing some files, and for a given file name I must know when that file was created, i mean date and time.
    Might be there is some simple way, please help out.
    regards
    CJ

    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:439619916584#73995149457661
    Remember to get the correct privs (java privs) on the directory.
    Mette

Maybe you are looking for

  • SSO and how to Managing User Roles/Privileges with Forms using Oracle db

    We are in the process of implementing Oracle Application Server SSO with our custom Forms application using Oracle database -- all 10.2.0.1.0 version. In our Forms Applications, we have about a dozen roles we have assigned to various users. We need t

  • Latest mac book pro to tv

    I have the latest 15 inch macbook pro. i'm now going to be traveling for around 10 days a month. i want to use my macbook as a 'dvd player', hooking it up to tvs in hotels. what hardware do i need? thanks, dave

  • How connect old Cinema Display

    I have one of the first Apple cinema displays. I have been using it with an old G-4 computer. It has a 30 pin plug. Can I connect if to a new Macbook Pro? How do I do it?

  • Restricted stock used in intra-company stock transfer

    Hi, Can anyone give me the link about the description and difference between unrestricted stock, restricted stock and blocked stock? And for intra-company stock transfer(in one company code), I would like to post goods issue with restriced stock. and

  • Error -: AIP-50025: Repository error : Error -: AIP-50143: Transaction Inst

    Hi, Hi Ramesh, The Scenario is as follows: 1. we are running a stub on WLI server(back end) which enques a message in to the JMS queue. 2.This JMS queue is used in the B2B internal delivery channel. 3.The message is coming to the B2B , however we are