Enter your keyword


Current Date in GregorianCalendar using java

Code snippet that will give Current date in GregorianCalendar format:

import java.util.GregorianCalendar;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

public class CurrentDate {
    public CurrentDate() {

    public static void main(String[] args) {
            XMLGregorianCalendar xgcal = null;
                try {
                    GregorianCalendar gcal =
                     xgcal =
                    System.out.println(“xgcal “+xgcal.toString());
                } catch (DatatypeConfigurationException dce) {
                   System.out.println(“Exception occurred while getting XMLGregorianCalendar “+dce);

Leave a Reply

Your email address will not be published.