Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Java >> Snippet

Get current date/time information


import java.util. * ;

class Clock {
   public statis void main(String[] arguments) {
      //get current time and data
    Calendar now = Calendar.getInstance() ;
      int hour = now.get(Calendar.HOUR_OF_DAY) ;
      int minute = now.get(Calendar.MINUTE) ;
      int month = now.get(Calendar.MONTH) + 1 ;
      int day = now.get(Calendar.DAY_OF_MONTH) ;
      int year = now.get(Calendar.YEAR) ;
   }