















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
These are the Lecture Slides of Java Programming Language which includes Applet Class, Passing Parameters to Applets, Conversions, Applications and Applets, Running a Program, Applet, Application, Mouse Event, Keyboard Event etc. Key important points are: Internationalization, Processing Date, Time, Locale, Date, Timezone, Calendar, Gregoriancalendar, Dateformat, Simpledateformat
Typology: Slides
1 / 23
This page cannot be seen from the preview
Don't miss anything!
















UTF-8 (8-bit for ASCII Char and 24-bit for other char)
To create a Locale object, you can use the following constructor in Locale class:
Locale(String language, String country)
Locale(String language, String country, String variant)
Language: iso639 Country code: iso
Example:
new Locale(“en”, “US”); or new Locale(“fr”, “CA”);
See Locale class for more methods: getDefault(), …
the following two constructors in this class:
public Date();
public Date(long time);
class method getTimeZone(), along with a time
zone ID.
standard time is CST. Therefore, you can get a
CST TimeZone object with the following:
TimeZone tz = TimeZone.getTimeZone("CST");
minute, and second.
public final void set(int field, int value) public final void set(int year,int month, int date)
public final int get(int field)
This retrieves the value for a given time field.
The parameter field is a constant, such as
YEAR , MONTH , DAY , HOUR , MINUTE, SECOND ,
DAY_OF_WEEK , DAY_OF_MONTH ,
DAY_OF_YEAR , WEEK_OF_MONTH ,
WEEK_OF_YEAR , and so on.
GregorianCalendar Example
GregorianCalendar rightNow = new GregorianCalendar(); System.out.println("week of the year is "+rightNow.get(GregorianCalendar.WEEK_OF_YEAR));
This displays the week of the year for the current time.
You can use the getDateTimeInstance() method
to obtain a DateFormat object:
public static final DateFormat getDateTimeInstance (int dateStyle, int timeStyle, Locale aLocale)
This gets the date and time formatter with the given
formatting styles for the given locale.
javaw CurrentTimeApplet en US CST
CurrentTimeApplet
Run as Application Run as Applet
CalendarApplet
Run as Application Run as Applet
NumberFormat percForm =
NumberFormat.getPercentInstance(locale);
String s = percForm.format(0.075);