SlideShare a Scribd company logo
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

Process scheduling
Process schedulingProcess scheduling
Process scheduling
Deepika Balichwal
 
Input-Buffering
Input-BufferingInput-Buffering
Input-Buffering
Dattatray Gandhmal
 
Packages in java
Packages in javaPackages in java
Packages in java
jamunaashok
 
Minimization of DFA
Minimization of DFAMinimization of DFA
Minimization of DFA
kunj desai
 
Thread model in java
Thread model in javaThread model in java
Thread model in java
AmbigaMurugesan
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Shiraz316
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design
Aman Sharma
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
swapnac12
 
Distributed file system
Distributed file systemDistributed file system
Distributed file system
Anamika Singh
 
standard template library(STL) in C++
standard template library(STL) in C++standard template library(STL) in C++
standard template library(STL) in C++
•sreejith •sree
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS
koolkampus
 
SQL, Embedded SQL, Dynamic SQL and SQLJ
SQL, Embedded SQL, Dynamic SQL and SQLJSQL, Embedded SQL, Dynamic SQL and SQLJ
SQL, Embedded SQL, Dynamic SQL and SQLJ
Dharita Chokshi
 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler Design
Kuppusamy P
 
Time and Space Complexity
Time and Space ComplexityTime and Space Complexity
Time and Space Complexity
Ashutosh Satapathy
 
Abstract class
Abstract classAbstract class
Abstract class
Tony Nguyen
 
Introduction to Python
Introduction to Python  Introduction to Python
Introduction to Python
Mohammed Sikander
 
Lecture 02 lexical analysis
Lecture 02 lexical analysisLecture 02 lexical analysis
Lecture 02 lexical analysis
Iffat Anjum
 
Java.util
Java.utilJava.util
Java.util
Ramakrishna kapa
 
Birch Algorithm With Solved Example
Birch Algorithm With Solved ExampleBirch Algorithm With Solved Example
Birch Algorithm With Solved Example
kailash shaw
 

What's hot (20)

Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
Input-Buffering
Input-BufferingInput-Buffering
Input-Buffering
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Minimization of DFA
Minimization of DFAMinimization of DFA
Minimization of DFA
 
Thread model in java
Thread model in javaThread model in java
Thread model in java
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 
Distributed file system
Distributed file systemDistributed file system
Distributed file system
 
standard template library(STL) in C++
standard template library(STL) in C++standard template library(STL) in C++
standard template library(STL) in C++
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS
 
SQL, Embedded SQL, Dynamic SQL and SQLJ
SQL, Embedded SQL, Dynamic SQL and SQLJSQL, Embedded SQL, Dynamic SQL and SQLJ
SQL, Embedded SQL, Dynamic SQL and SQLJ
 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler Design
 
Time and Space Complexity
Time and Space ComplexityTime and Space Complexity
Time and Space Complexity
 
Abstract class
Abstract classAbstract class
Abstract class
 
Introduction to Python
Introduction to Python  Introduction to Python
Introduction to Python
 
Lecture 02 lexical analysis
Lecture 02 lexical analysisLecture 02 lexical analysis
Lecture 02 lexical analysis
 
Java.util
Java.utilJava.util
Java.util
 
Birch Algorithm With Solved Example
Birch Algorithm With Solved ExampleBirch Algorithm With Solved Example
Birch Algorithm With Solved Example
 

Viewers also liked

My Work Experience
My Work ExperienceMy Work Experience
My Work Experience
Cindy Pettett
 
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
 
Matthew Dillon
Matthew DillonMatthew Dillon
Matthew Dillon
Matt Dillon
 
Rob Williams Resume usa
Rob Williams Resume usaRob Williams Resume usa
Rob Williams Resume usa
Rob 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 Presentation
Gopi Krishna Mandadi
 
Nesia 2016
Nesia 2016Nesia 2016
Nesia 2016
Tantan Sultandi
 
Corporate_Presentation_v8.20.16_revisedMGL
Corporate_Presentation_v8.20.16_revisedMGLCorporate_Presentation_v8.20.16_revisedMGL
Corporate_Presentation_v8.20.16_revisedMGL
Martin G. Lee
 
Error en medicina 2016
Error en medicina 2016Error en medicina 2016
Error en medicina 2016
Carlos M Erazo
 
Psychological horror characters – in depth
Psychological horror characters – in depthPsychological horror characters – in depth
Psychological horror characters – in depth
DylanWilson99
 
Hanson Springs - SPE Offshore Europe
Hanson Springs - SPE Offshore EuropeHanson Springs - SPE Offshore Europe
Hanson Springs - SPE Offshore Europe
SPE 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

Ds
DsDs
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
Buddha Jyothiprasad
 
Data structure introduction
Data structure introductionData structure introduction
Data structure introduction
NavneetSandhu0
 
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
hishamrizvi
 
IRJET- Syllabus and Timetable Generation System
IRJET- Syllabus and Timetable Generation SystemIRJET- Syllabus and Timetable Generation System
IRJET- Syllabus and Timetable Generation System
IRJET Journal
 
Numerical data.
Numerical data.Numerical data.
Numerical data.
Adewumi Ezekiel Adebayo
 
Java22_1670144363.pptx
Java22_1670144363.pptxJava22_1670144363.pptx
Java22_1670144363.pptx
DilanAlmsa
 
Java 8 date & time
Java 8 date & timeJava 8 date & time
Java 8 date & time
Oleg Tsal-Tsalko
 
220 runtime environments
220 runtime environments220 runtime environments
220 runtime environments
J'tong Atong
 
Bad Smells in Code
Bad Smells in CodeBad Smells in Code
Bad Smells in Code
Özge Nur KOÇ
 
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
sg4795
 
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
Manoj Kumar kothagulla
 
Timer class in java
Timer class in javaTimer class in java
Timer class in java
Muthukumaran Subramanian
 
Scala tutorial
Scala tutorialScala tutorial
Scala tutorial
Murali Krishna
 
Scala tutorial
Scala tutorialScala tutorial
Scala tutorial
wafianedjma
 
Unit i
Unit iUnit i
Unit i
snehaarao19
 
oops-1
oops-1oops-1
oops-1
snehaarao19
 
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
Mani .S (Specialization in Semantic Web)
 
Storage classes
Storage classesStorage classes
Storage classes
Praveen M Jigajinni
 
Data structures
Data structuresData structures
Data structures
Saurabh Mishra
 

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
 
Unit i
Unit iUnit i
Unit i
 
oops-1
oops-1oops-1
oops-1
 
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

GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
lorraineandreiamcidl
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 

Recently uploaded (20)

GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 

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.