Open In App

TextStyle isStandalone() method in Java with Examples

Improve
Improve
Like Article
Like
Save
Share
Report

The isStandalone() method of TextStyle enum is used to return true if the TextStyle is a stand-alone style.

Syntax:

public TextStyle isStandalone()

Parameters: This method accepts nothing.

Return value: This method returns true if the style is a stand-alone style.

Below programs illustrate the TextStyle.isStandalone() method:
Program 1:




// Java program to demonstrate
// TextStyle.isStandalone() method
  
import java.time.format.TextStyle;
  
public class GFG {
    public static void main(String[] args)
    {
  
        // get TextStyle
        TextStyle style
            = TextStyle.valueOf(
                "SHORT_STANDALONE");
  
        // apply isStandalone()
        boolean isStandaloneAttribute
            = style.isStandalone();
  
        // print
        System.out.println(
            "TextStyle is Standalone:"
            + isStandaloneAttribute);
    }
}


Output:

TextStyle is Standalone:true

Program 2:




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


Output:

TextStyle is Standalone:false

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



Last Updated : 29 Jan, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads