12:39 am - Monday August 21, 2017

Calendar in java example program get Instance(TimeZone zone, Locale aLocale)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

/**

*@author:candidjava.com

*@description: Calender in java example program getInstance(TimeZone zone,Locale aLocale)
*/

import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;
public class CalendarGetInstance
{
public static void main(String[] args) {Locale locale1 = Locale.CANADA;
{
TimeZone tz1 = TimeZone.getTimeZone("GMT"); // create a calendar
Calendar cal1 = Calendar.getInstance(tz1, locale1);
Locale locale2 = Locale.GERMANY;
TimeZone tz2 = TimeZone.getTimeZone("EST"); // create a second calendar with different timezone and locale
Calendar cal2 = Calendar.getInstance(tz2, locale2);
String tzname1 = tz1.getDisplayName(); // display time zone for both calendars
String tzname2 = tz2.getDisplayName();
String name1 = locale1.getDisplayName();
String name2 = locale2.getDisplayName();
System.out.println("GMT and Canada: " + tzname1 + " " + name1);
System.out.println("EST and Germany: " + tzname2 + " " + name2);
}
}

OUTPUT:
GMT and Canada: Greenwich Mean Time English (Canada)
EST and Germany: Eastern Standard Time German (Germany)

 

BACK

Filed in: Z-A All Java Codes

Comments are closed.