Wednesday, July 3, 2024
HomeLanguagesJavaTextStyle asStandalone() method in Java with Examples

TextStyle asStandalone() method in Java with Examples

The asStandalone() method of TextStyle enum is used to return the stand-alone style with the same size of this TextStyle object.

Syntax:

public TextStyle asStandalone()

Parameters: This method accepts nothing.

Return value: This method returns the stand-alone style with the same size.

Below programs illustrate the TextStyle.asStandalone() method:

Program 1: 

Java




// Java program to demonstrate// TextStyle.asStandalone() methodimport java.time.format.TextStyle;public class GFG {    public static void main(String[] args)    {        // get TextStyle        TextStyle style            = TextStyle.valueOf("SHORT");        // apply asStandalone()        TextStyle asStandaloneAttribute            = style.asStandalone();        // print        System.out.println(            "Standalone TextStyle :"            + asStandaloneAttribute);    }}


Output:

Standalone TextStyle :SHORT_STANDALONE

Program 2: 

Java




// Java program to demonstrate// TextStyle.asStandalone() methodimport java.time.format.TextStyle;public class GFG {    public static void main(String[] args)    {        // get TextStyle        TextStyle style            = TextStyle.valueOf("FULL");        // apply asStandalone()        TextStyle asStandaloneAttribute            = style.asStandalone();        // print        System.out.println("Standalone TextStyle :"                           + asStandaloneAttribute);    }}


Output:

Standalone TextStyle :FULL_STANDALONE

References: https://docs.oracle.com/javase/10/docs/api/java/time/format/TextStyle.html#asStandalone()

Nokonwaba Nkukhwana
Experience as a skilled Java developer and proven expertise in using tools and technical developments to drive improvements throughout a entire software development life cycle. I have extensive industry and full life cycle experience in a java based environment, along with exceptional analytical, design and problem solving capabilities combined with excellent communication skills and ability to work alongside teams to define and refine new functionality. Currently working in springboot projects(microservices). Considering the fact that change is good, I am always keen to new challenges and growth to sharpen my skills.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments