Example usage for java.util GregorianCalendar getTime

List of usage examples for java.util GregorianCalendar getTime

Introduction

In this page you can find the example usage for java.util GregorianCalendar getTime.

Prototype

public final Date getTime() 

Source Link

Document

Returns a Date object representing this Calendar's time value (millisecond offset from the Epoch").

Usage

From source file:Main.java

public static void main(String[] args) {

    GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();

    System.out.println(cal.getTime());

    System.out.println(cal.isWeekDateSupported());

}

From source file:Main.java

public static void main(String[] args) {

    GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();

    System.out.println(cal.getTime());

    System.out.println(cal.getWeekYear());

}

From source file:Main.java

public static void main(String[] args) {

    GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();

    System.out.println(cal.getTime());

    System.out.println(cal.getWeeksInWeekYear());

}

From source file:Main.java

public static void main(String[] args) {

    GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();

    System.out.println(cal.getTime());

    cal.setWeekDate(2013, 1, 3);/*from  w  w  w . j a va  2  s. co  m*/

    System.out.println(cal.getTime());

}

From source file:Main.java

public static void main(String[] args) {

    GregorianCalendar cal = new GregorianCalendar(TimeZone.getDefault(), Locale.getDefault());

    System.out.println(cal.getTime());

}

From source file:DateComboBoxRenderer.java

public static void main(String[] str) {
    JComboBox combo = new JComboBox();
    GregorianCalendar calendar = new GregorianCalendar();
    combo.addItem(calendar.getTime());

    calendar.roll(GregorianCalendar.DAY_OF_MONTH, 1);
    combo.addItem(calendar.getTime());/*from  w ww  .ja  v  a 2s .  c o m*/

    combo.setRenderer(new DateComboBoxRenderer());

    JFrame frame = new JFrame();

    JPanel panel = new JPanel();
    panel.add(new JLabel("Date Combo: "));
    panel.add(combo);

    frame.add(panel);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {

    GregorianCalendar cal = new GregorianCalendar();

    cal.set(Calendar.ERA, GregorianCalendar.BC);

    System.out.println(cal.getTime());

}

From source file:Main.java

public static void main(String[] args) {

    GregorianCalendar cal = new GregorianCalendar();

    cal.set(Calendar.ERA, GregorianCalendar.AD);

    System.out.println(cal.getTime());

}

From source file:Main.java

public static void main(String[] args) {

    GregorianCalendar cal1 = (GregorianCalendar) GregorianCalendar.getInstance();

    // create a second calendar equal to first one
    GregorianCalendar cal2 = (GregorianCalendar) (Calendar) cal1.clone();

    // print cal2
    System.out.println(cal2.getTime());

    // compare the two calendars
    System.out.println("Cal1 and Cal2 are equal:" + cal1.equals(cal2));

    // change cal 2 a bit
    cal2.add(GregorianCalendar.YEAR, 5);

    // compare the two calendars
    System.out.println("Cal1 and Cal2 are equal:" + cal1.equals(cal2));

}

From source file:Main.java

public static void main(String[] args) {
    GregorianCalendar gc = new GregorianCalendar(2014, 1, 11, 15, 45, 50);
    LocalDate ld = gc.toZonedDateTime().toLocalDate();
    System.out.println("Local  Date: " + ld);

    LocalTime lt = gc.toZonedDateTime().toLocalTime();
    System.out.println("Local Time:  " + lt);

    LocalDateTime ldt = gc.toZonedDateTime().toLocalDateTime();
    System.out.println("Local DateTime:  " + ldt);

    OffsetDateTime od = gc.toZonedDateTime().toOffsetDateTime();
    System.out.println("Offset  Date: " + od);

    OffsetTime ot = gc.toZonedDateTime().toOffsetDateTime().toOffsetTime();
    System.out.println("Offset Time:  " + ot);

    ZonedDateTime zdt = gc.toZonedDateTime();
    System.out.println("Zoned DateTime:  " + zdt);

    ZoneId zoneId = zdt.getZone();
    TimeZone timeZone = TimeZone.getTimeZone(zoneId);
    System.out.println("Zone ID:  " + zoneId);
    System.out.println("Time Zone ID:  " + timeZone.getID());

    GregorianCalendar gc2 = GregorianCalendar.from(zdt);
    System.out.println("Gregorian  Calendar: " + gc2.getTime());
}