SlideShare a Scribd company logo
1 of 18
Java Utility Classes
Sourabrata Mukherjee
Topics
1. Basics
2. StringTokenizer
3. Date
4. Calendar
5. Timezone
6. Locale
7. Formatter
Basics
What is a util?
The util (also frequently used in plural as utils) is the common
textbook/classroom unit used to discuss the utility derived from consumption.
What is a utility class?
In computer programming, a utility class is a class that defines a set of methods
that perform common, often re-used functions. Most utility classes define these
common methods under static scope.
String Tokenizer
The java.util.StringTokenizer class allows an application to break a string into
tokens.
This class is a legacy class that is retained for compatibility reasons although its
use is discouraged in new code.
Its methods do not distinguish among identifiers, numbers, and quoted strings.
This class methods do not even recognize and skip comments.
*StringTokenizer class is deprecated now. It is recommended to use split() method of String class or regex (Regular
Expression).
Continue
A StringTokenizer object internally maintains a current position within the string to
be tokenized. Some operations advance this current position past the characters
processed.
A token is returned by taking a substring of the string that was used to create the
StringTokenizer object.
Continue..
Multiple Delimiters:
Each character in the constructors delimiter field acts as one delimiter.
Continue..
Date
The java.util.Date class represents a specific instant in time, with millisecond
precision.
Although the Date class is intended to reflect coordinated universal time (UTC), it
may not do so exactly, depending on the host environment of the Java Virtual
Machine. Nearly all modern operating systems assume that 1 day = 24 × 60 × 60 =
86400 seconds in all cases. In UTC, however, about once every year or two there is
an extra second, called a "leap second." The leap second is always added as the
last second of the day, and always on December 31 or June 30. For example, the
last minute of the year 1995 was 61 seconds long, thanks to an added leap
second. Most computer clocks are not accurate enough to be able to reflect the
leap-second distinction.
Calendar
The java.util.calendar class is an abstract class that provides methods for
converting between a specific instant in time and a set of calendar fields such as
YEAR, MONTH, DAY_OF_MONTH, HOUR, and so on, and for manipulating the
calendar fields, such as getting the date of the next week.
Following are the important points about Calendar:
This class also provides additional fields and methods for implementing a
concrete calendar system outside the package.
Calendar defines the range of values returned by certain calendar fields.
TimeZone
A time zone is a region of the earth where the same standard time is used. Each
time zone is described by an identifier and usually has the format region/city
(Asia/Tokyo) and an offset from Greenwich/UTC time.
UTC:
Coordinated Universal Time, abbreviated as UTC, is the primary time standard by
which the world regulates clocks and time. It is within about 1 second of mean
solar time at 0° longitude, it does not observe daylight saving time.
Continue..
Daylight saving time (DST) or summer time is the practice of advancing clocks
during summer months by one hour so that evening daylight lasts an hour longer,
while sacrificing normal sunrise times. Typically, regions with summer time adjust
clocks forward one hour close to the start of spring and adjust them backward in
the autumn to standard time. People use the terms "spring forward" and "fall back"
when referring to this.
The Java TimeZone class is a class that represents time zones, and is helpful
when doing calendar arithmetics across time zones.
Continue..
Typically, you get a TimeZone using getDefault which creates a TimeZone based
on the time zone where the program is running. For example, for a program
running in Japan, getDefault creates a TimeZone object based on Japanese
Standard Time. You can also get a TimeZone using getTimeZone along with a
time zone ID. For instance, the time zone ID for the U.S. Pacific Time zone is
"America/Los_Angeles". So, you can get a U.S. Pacific Time TimeZone object with:
TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
Locale
A Locale object represents a specific geographical, political, or cultural region. An
operation that requires a Locale to perform its task is called locale-sensitive and
uses the Locale to tailor information for the user. For example, displaying a
number is a locale-sensitive operation— the number should be formatted
according to the customs and conventions of the user's native country, region, or
culture.
Timer
The java.util.Timer class provides facility for threads to schedule tasks for future
execution in a background thread.
This class is thread-safe i.e multiple threads can share a single Timer object
without the need for external synchronization.
This class schedules tasks for one-time execution, or for repeated execution at
regular intervals.
All constructors start a timer thread.
Continue..
The java.util.TimerTask class represents a task that can be scheduled for one-
time or repeated execution by a Timer.
Formatter
A formatter is an object that is responsible for encoding and serializing data into
messages on one end, and deserializing and decoding messages into data on the
other end.
The java.util.Formatter class provides support for layout justification and
alignment, common formats for numeric, string, and date/time data, and locale-
specific output
Continue..
Difference between the printf and format methods in Java?
printf() and format()both methods are used to format String in Java and more or
less similar. printf()is more close to C programming language because of identical
name used in C programming language, Anyone who has work in C previously can
easily start with this printf() method also its look more as a replacement of
System.out.println(). if you don't want to print just want a formatted string for any
other purpose String format() method is a way to go. In summary you can say that
printf()writes on stdout while format() return you a formatted string.
Thank You

More Related Content

What's hot

Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVAAbhilash Nair
 
Garbage collection
Garbage collectionGarbage collection
Garbage collectionSomya Bagai
 
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in javaHitesh Kumar
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)swapnac12
 
Peephole optimization techniques in compiler design
Peephole optimization techniques in compiler designPeephole optimization techniques in compiler design
Peephole optimization techniques in compiler designAnul Chaudhary
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in javaTech_MX
 
Introduction to java beans
Introduction to java beansIntroduction to java beans
Introduction to java beansHitesh Parmar
 
Java package
Java packageJava package
Java packageCS_GDRCST
 
Type casting in java
Type casting in javaType casting in java
Type casting in javaFarooq Baloch
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in JavaNiloy Saha
 
Constructor in java
Constructor in javaConstructor in java
Constructor in javaHitesh Kumar
 

What's hot (20)

Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
Templates
TemplatesTemplates
Templates
 
Garbage collection
Garbage collectionGarbage collection
Garbage collection
 
Java program structure
Java program structureJava program structure
Java program structure
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
 
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 
Peephole optimization techniques in compiler design
Peephole optimization techniques in compiler designPeephole optimization techniques in compiler design
Peephole optimization techniques in compiler design
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Java packages
Java packagesJava packages
Java packages
 
Introduction to java beans
Introduction to java beansIntroduction to java beans
Introduction to java beans
 
Java package
Java packageJava package
Java package
 
Symbol Table
Symbol TableSymbol Table
Symbol Table
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
 
Java input
Java inputJava input
Java input
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 

Viewers also liked

Pavel Dabrytski & Angie Doyle - Agile Africa 2015 - User-Centered design usin...
Pavel Dabrytski & Angie Doyle - Agile Africa 2015 - User-Centered design usin...Pavel Dabrytski & Angie Doyle - Agile Africa 2015 - User-Centered design usin...
Pavel Dabrytski & Angie Doyle - Agile Africa 2015 - User-Centered design usin...IQ Business - agility@IQ
 
Rob Williams Resume usa
Rob Williams Resume usaRob Williams Resume usa
Rob Williams Resume usaRob Williams
 
Mandadi_Gopi Krishna_Spring 2016 Thesis Presentation
Mandadi_Gopi Krishna_Spring 2016 Thesis PresentationMandadi_Gopi Krishna_Spring 2016 Thesis Presentation
Mandadi_Gopi Krishna_Spring 2016 Thesis PresentationGopi Krishna Mandadi
 
Corporate_Presentation_v8.20.16_revisedMGL
Corporate_Presentation_v8.20.16_revisedMGLCorporate_Presentation_v8.20.16_revisedMGL
Corporate_Presentation_v8.20.16_revisedMGLMartin G. Lee
 
Error en medicina 2016
Error en medicina 2016Error en medicina 2016
Error en medicina 2016Carlos M Erazo
 
Psychological horror characters – in depth
Psychological horror characters – in depthPsychological horror characters – in depth
Psychological horror characters – in depthDylanWilson99
 
Hanson Springs - SPE Offshore Europe
Hanson Springs - SPE Offshore EuropeHanson Springs - SPE Offshore Europe
Hanson Springs - SPE Offshore EuropeSPE Offshore Europe
 

Viewers also liked (11)

My Work Experience
My Work ExperienceMy Work Experience
My Work Experience
 
Pavel Dabrytski & Angie Doyle - Agile Africa 2015 - User-Centered design usin...
Pavel Dabrytski & Angie Doyle - Agile Africa 2015 - User-Centered design usin...Pavel Dabrytski & Angie Doyle - Agile Africa 2015 - User-Centered design usin...
Pavel Dabrytski & Angie Doyle - Agile Africa 2015 - User-Centered design usin...
 
Matthew Dillon
Matthew DillonMatthew Dillon
Matthew Dillon
 
NSLS
NSLSNSLS
NSLS
 
Rob Williams Resume usa
Rob Williams Resume usaRob Williams Resume usa
Rob Williams Resume usa
 
Mandadi_Gopi Krishna_Spring 2016 Thesis Presentation
Mandadi_Gopi Krishna_Spring 2016 Thesis PresentationMandadi_Gopi Krishna_Spring 2016 Thesis Presentation
Mandadi_Gopi Krishna_Spring 2016 Thesis Presentation
 
Nesia 2016
Nesia 2016Nesia 2016
Nesia 2016
 
Corporate_Presentation_v8.20.16_revisedMGL
Corporate_Presentation_v8.20.16_revisedMGLCorporate_Presentation_v8.20.16_revisedMGL
Corporate_Presentation_v8.20.16_revisedMGL
 
Error en medicina 2016
Error en medicina 2016Error en medicina 2016
Error en medicina 2016
 
Psychological horror characters – in depth
Psychological horror characters – in depthPsychological horror characters – in depth
Psychological horror characters – in depth
 
Hanson Springs - SPE Offshore Europe
Hanson Springs - SPE Offshore EuropeHanson Springs - SPE Offshore Europe
Hanson Springs - SPE Offshore Europe
 

Similar to Java utility classes

A Quick peek @ New Date & Time API of Java 8
A Quick peek @ New Date & Time API of Java 8A Quick peek @ New Date & Time API of Java 8
A Quick peek @ New Date & Time API of Java 8Buddha Jyothiprasad
 
Data structure introduction
Data structure introductionData structure introduction
Data structure introductionNavneetSandhu0
 
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Examshishamrizvi
 
IRJET- Syllabus and Timetable Generation System
IRJET- Syllabus and Timetable Generation SystemIRJET- Syllabus and Timetable Generation System
IRJET- Syllabus and Timetable Generation SystemIRJET Journal
 
Java22_1670144363.pptx
Java22_1670144363.pptxJava22_1670144363.pptx
Java22_1670144363.pptxDilanAlmsa
 
220 runtime environments
220 runtime environments220 runtime environments
220 runtime environmentsJ'tong Atong
 
Kripanshu MOOC PPT - Kripanshu Shekhar Jha (1).pptx
Kripanshu MOOC PPT - Kripanshu Shekhar Jha (1).pptxKripanshu MOOC PPT - Kripanshu Shekhar Jha (1).pptx
Kripanshu MOOC PPT - Kripanshu Shekhar Jha (1).pptxsg4795
 
C basic questions&ansrs by shiva kumar kella
C basic questions&ansrs by shiva kumar kellaC basic questions&ansrs by shiva kumar kella
C basic questions&ansrs by shiva kumar kellaManoj Kumar kothagulla
 

Similar to Java utility classes (20)

Ds
DsDs
Ds
 
A Quick peek @ New Date & Time API of Java 8
A Quick peek @ New Date & Time API of Java 8A Quick peek @ New Date & Time API of Java 8
A Quick peek @ New Date & Time API of Java 8
 
Data structure introduction
Data structure introductionData structure introduction
Data structure introduction
 
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
 
IRJET- Syllabus and Timetable Generation System
IRJET- Syllabus and Timetable Generation SystemIRJET- Syllabus and Timetable Generation System
IRJET- Syllabus and Timetable Generation System
 
Numerical data.
Numerical data.Numerical data.
Numerical data.
 
Java22_1670144363.pptx
Java22_1670144363.pptxJava22_1670144363.pptx
Java22_1670144363.pptx
 
Java 8 date & time
Java 8 date & timeJava 8 date & time
Java 8 date & time
 
220 runtime environments
220 runtime environments220 runtime environments
220 runtime environments
 
Bad Smells in Code
Bad Smells in CodeBad Smells in Code
Bad Smells in Code
 
Kripanshu MOOC PPT - Kripanshu Shekhar Jha (1).pptx
Kripanshu MOOC PPT - Kripanshu Shekhar Jha (1).pptxKripanshu MOOC PPT - Kripanshu Shekhar Jha (1).pptx
Kripanshu MOOC PPT - Kripanshu Shekhar Jha (1).pptx
 
C basic questions&ansrs by shiva kumar kella
C basic questions&ansrs by shiva kumar kellaC basic questions&ansrs by shiva kumar kella
C basic questions&ansrs by shiva kumar kella
 
Timer class in java
Timer class in javaTimer class in java
Timer class in java
 
Scala tutorial
Scala tutorialScala tutorial
Scala tutorial
 
Scala tutorial
Scala tutorialScala tutorial
Scala tutorial
 
oops-1
oops-1oops-1
oops-1
 
Unit i
Unit iUnit i
Unit i
 
Time Complexity Analysis in Data Structure.docx
Time Complexity Analysis in Data Structure.docxTime Complexity Analysis in Data Structure.docx
Time Complexity Analysis in Data Structure.docx
 
Storage classes
Storage classesStorage classes
Storage classes
 
Data structures
Data structuresData structures
Data structures
 

Recently uploaded

Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 

Recently uploaded (20)

Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 

Java utility classes

  • 2. Topics 1. Basics 2. StringTokenizer 3. Date 4. Calendar 5. Timezone 6. Locale 7. Formatter
  • 3. Basics What is a util? The util (also frequently used in plural as utils) is the common textbook/classroom unit used to discuss the utility derived from consumption. What is a utility class? In computer programming, a utility class is a class that defines a set of methods that perform common, often re-used functions. Most utility classes define these common methods under static scope.
  • 4. String Tokenizer The java.util.StringTokenizer class allows an application to break a string into tokens. This class is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. Its methods do not distinguish among identifiers, numbers, and quoted strings. This class methods do not even recognize and skip comments. *StringTokenizer class is deprecated now. It is recommended to use split() method of String class or regex (Regular Expression).
  • 5. Continue A StringTokenizer object internally maintains a current position within the string to be tokenized. Some operations advance this current position past the characters processed. A token is returned by taking a substring of the string that was used to create the StringTokenizer object.
  • 6. Continue.. Multiple Delimiters: Each character in the constructors delimiter field acts as one delimiter.
  • 8. Date The java.util.Date class represents a specific instant in time, with millisecond precision. Although the Date class is intended to reflect coordinated universal time (UTC), it may not do so exactly, depending on the host environment of the Java Virtual Machine. Nearly all modern operating systems assume that 1 day = 24 × 60 × 60 = 86400 seconds in all cases. In UTC, however, about once every year or two there is an extra second, called a "leap second." The leap second is always added as the last second of the day, and always on December 31 or June 30. For example, the last minute of the year 1995 was 61 seconds long, thanks to an added leap second. Most computer clocks are not accurate enough to be able to reflect the leap-second distinction.
  • 9. Calendar The java.util.calendar class is an abstract class that provides methods for converting between a specific instant in time and a set of calendar fields such as YEAR, MONTH, DAY_OF_MONTH, HOUR, and so on, and for manipulating the calendar fields, such as getting the date of the next week. Following are the important points about Calendar: This class also provides additional fields and methods for implementing a concrete calendar system outside the package. Calendar defines the range of values returned by certain calendar fields.
  • 10. TimeZone A time zone is a region of the earth where the same standard time is used. Each time zone is described by an identifier and usually has the format region/city (Asia/Tokyo) and an offset from Greenwich/UTC time. UTC: Coordinated Universal Time, abbreviated as UTC, is the primary time standard by which the world regulates clocks and time. It is within about 1 second of mean solar time at 0° longitude, it does not observe daylight saving time.
  • 11. Continue.. Daylight saving time (DST) or summer time is the practice of advancing clocks during summer months by one hour so that evening daylight lasts an hour longer, while sacrificing normal sunrise times. Typically, regions with summer time adjust clocks forward one hour close to the start of spring and adjust them backward in the autumn to standard time. People use the terms "spring forward" and "fall back" when referring to this. The Java TimeZone class is a class that represents time zones, and is helpful when doing calendar arithmetics across time zones.
  • 12. Continue.. Typically, you get a TimeZone using getDefault which creates a TimeZone based on the time zone where the program is running. For example, for a program running in Japan, getDefault creates a TimeZone object based on Japanese Standard Time. You can also get a TimeZone using getTimeZone along with a time zone ID. For instance, the time zone ID for the U.S. Pacific Time zone is "America/Los_Angeles". So, you can get a U.S. Pacific Time TimeZone object with: TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
  • 13. Locale A Locale object represents a specific geographical, political, or cultural region. An operation that requires a Locale to perform its task is called locale-sensitive and uses the Locale to tailor information for the user. For example, displaying a number is a locale-sensitive operation— the number should be formatted according to the customs and conventions of the user's native country, region, or culture.
  • 14. Timer The java.util.Timer class provides facility for threads to schedule tasks for future execution in a background thread. This class is thread-safe i.e multiple threads can share a single Timer object without the need for external synchronization. This class schedules tasks for one-time execution, or for repeated execution at regular intervals. All constructors start a timer thread.
  • 15. Continue.. The java.util.TimerTask class represents a task that can be scheduled for one- time or repeated execution by a Timer.
  • 16. Formatter A formatter is an object that is responsible for encoding and serializing data into messages on one end, and deserializing and decoding messages into data on the other end. The java.util.Formatter class provides support for layout justification and alignment, common formats for numeric, string, and date/time data, and locale- specific output
  • 17. Continue.. Difference between the printf and format methods in Java? printf() and format()both methods are used to format String in Java and more or less similar. printf()is more close to C programming language because of identical name used in C programming language, Anyone who has work in C previously can easily start with this printf() method also its look more as a replacement of System.out.println(). if you don't want to print just want a formatted string for any other purpose String format() method is a way to go. In summary you can say that printf()writes on stdout while format() return you a formatted string.