Code example for GregorianCalendar

Methods: setTimesetTimeZone

    public static String getCurrentTime() {
        // Create a calendar to work with.  
        GregorianCalendar gc = new GregorianCalendar(Locale.US); 
        // Create a timezone object to set ont eh calendar.  
        TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles"); 
        // Set the timezone.  
        // Set the date.  
        gc.setTime(new Date()); 
        // Format the date  
        SimpleDateFormat sdf = new SimpleDateFormat("dd MMMMM yyyy, H:mm:ss:FF");
        // Give the date format a calendar to work with.  
        // Create a string out of the date for display on the page.  
        String sDate = sdf.format(sdf.getCalendar().getTime());