Total members 10261 | Gratitudes |It is currently Wed May 23, 2012 8:14 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 2 posts ] 
Author Question
 Question subject: DOUBT
PostPosted: Wed Sep 07, 2011 3:12 pm 

HOW TO GET AN SYSTEMTIME IN JAVACODE


TOP
  
Reply with quote  
 Question subject: Re: DOUBT
PostPosted: Thu Sep 08, 2011 10:05 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time
Code:

 
package TextAreaExample
;

import java.text.SimpleDateFormat;
import java.util.Calendar;


public class ExampleClass {

    public static void main(String[] args) {

        // Create a calendar instance with system current time.
        Calendar calendar = Calendar.getInstance();

        // Formating the time .
        SimpleDateFormat dateFormat = new SimpleDateFormat("H:mm:ss:SSS");
        System.out.println("Current Time(H:mm:ss:SSS) :" + dateFormat.format(calendar.getTime()));

        // Another Format
        dateFormat = new SimpleDateFormat("yyyyMMdd");
        System.out.println("Current Time(yyyyMMdd):" + dateFormat.format(calendar.getTime()));

        // Custom Formating.
        int currentHour = calendar.get(Calendar.HOUR);
        int currentMinute = calendar.get(Calendar.MINUTE);
        int currentSeconds = calendar.get(Calendar.SECOND);

        String amOrpm="";

        if(calendar.get(Calendar.AM)==1){
            amOrpm="PM";
        }else
        {
            amOrpm="AM";
        }

        System.out.println("H:"+currentHour+",m:"+currentMinute+",s:"+currentSeconds+":"+amOrpm);
        
    
}
}
 

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 2 posts ] 
Quick reply


  

 Similar topics
 SERVLET/JSP DOUBT
 doubt
 Doubt in html:options tag

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 2 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team