Using Calendar in java. Getting a compilation error of cannot find symbol [duplicate]What does a “Cannot find symbol” compilation error mean?Method undefined for type JavaDoes a finally block always get executed in Java?How to get an enum value from a string value in Java?Get current stack trace in JavaJava Date vs CalendarGetting the Current Working Directory in JavaIntelliJ inspection gives “Cannot resolve symbol” but still compiles codeHow to get another Calendar result from same instance?What does a “Cannot find symbol” compilation error mean?Java compiler errors in UbuntuWhy Calendar.SEPTEMBER is not working?

Understanding STM32 datasheet regarding decoupling capacitors

etoolbox: AtBeginEnvironment is not At Begin Environment

Is this light switch installation safe and legal?

How can a single Member of the House block a Congressional bill?

How to make the POV character sit on the sidelines without the reader getting bored

Possible nonclassical ion from a bicyclic system

Why would Lupin kill Pettigrew?

How can I grammatically understand "Wir über uns"?

Where can I find the list of all tendons in the human body?

How to detach yourself from a character you're going to kill?

How can I offer a test ride while selling a bike?

Will My Circuit Work As intended?

How to capture more stars?

Points within polygons in different projections

Is a hash a zero-knowledge proof?

Asking bank to reduce APR instead of increasing credit limit

Why were the Night's Watch required to be celibate?

When a current flow in an inductor is interrupted, what limits the voltage rise?

Select row of data if next row contains zero

How was Apollo supposed to rendezvous in the case of a lunar abort?

Is there an evolutionary advantage to having two heads?

If a problem only occurs randomly once in every N times on average, how many tests do I have to perform to be certain that it's now fixed?

How crucial is a waifu game storyline?

Differences between “pas vrai ?”, “c’est ça ?”, “hein ?”, and “n’est-ce pas ?”



Using Calendar in java. Getting a compilation error of cannot find symbol [duplicate]


What does a “Cannot find symbol” compilation error mean?Method undefined for type JavaDoes a finally block always get executed in Java?How to get an enum value from a string value in Java?Get current stack trace in JavaJava Date vs CalendarGetting the Current Working Directory in JavaIntelliJ inspection gives “Cannot resolve symbol” but still compiles codeHow to get another Calendar result from same instance?What does a “Cannot find symbol” compilation error mean?Java compiler errors in UbuntuWhy Calendar.SEPTEMBER is not working?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0
















This question already has an answer here:



  • Method undefined for type Java

    1 answer



  • What does a “Cannot find symbol” compilation error mean?

    10 answers



I am getting error for cannot find symbol



getInstance(),Calendar.DATE,Calendar.MONTH,Calendar.YEAR



This only occurs when I am running offline on VS Code.
On running in on an online IDE (Hacker Rank), I get compilation successful.
JDK 11 on desktop, JDK 8 on Hacker Rank.
I have tried running it on multiple IDEs and get compilation successful only on JDK 8



import java.util.*;
import java.lang.*;
import java.io.*;

class Calendar
public static void main(String[] args)
Scanner sc = new Scanner(System.in);
int day = sc.nextInt();
int month = sc.nextInt();
int year = sc.nextInt();
Calendar c = Calendar.getInstance();
c.set(Calendar.DATE, day);
c.set(Calendar.MONTH, month - 1);
c.set(Calendar.YEAR, year);

System.out.println(c.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, new Locale("en", "US")).toUpperCase());












share|improve this question















marked as duplicate by Ole V.V. java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 24 at 13:12


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.













  • 1





    I recommend you don’t use Calendar. That class is poorly designed and long outdated. For your use you probably need LocalDate from java.time, the modern Java date and time API instead: LocalDate.of(year, month, day).

    – Ole V.V.
    Mar 24 at 10:24












  • By VS do you mean Visual Studio?? Could you show us your import statement?

    – Ole V.V.
    Mar 24 at 10:25







  • 1





    Can you reduce your code to a minimum that still reproduces the error and then include full source code? It sounds a lot like you're missing an import but can't be sure.

    – JussiV
    Mar 24 at 10:25






  • 3





    Don't name your class Calendar when you what do use java.util.Calendar!

    – Edwardth
    Mar 24 at 10:30











  • Easy and modern way: System.out.println(LocalDate.of(year, month, day).getDayOfWeek());. Prints for example SUNDAY..

    – Ole V.V.
    Mar 24 at 13:16

















0
















This question already has an answer here:



  • Method undefined for type Java

    1 answer



  • What does a “Cannot find symbol” compilation error mean?

    10 answers



I am getting error for cannot find symbol



getInstance(),Calendar.DATE,Calendar.MONTH,Calendar.YEAR



This only occurs when I am running offline on VS Code.
On running in on an online IDE (Hacker Rank), I get compilation successful.
JDK 11 on desktop, JDK 8 on Hacker Rank.
I have tried running it on multiple IDEs and get compilation successful only on JDK 8



import java.util.*;
import java.lang.*;
import java.io.*;

class Calendar
public static void main(String[] args)
Scanner sc = new Scanner(System.in);
int day = sc.nextInt();
int month = sc.nextInt();
int year = sc.nextInt();
Calendar c = Calendar.getInstance();
c.set(Calendar.DATE, day);
c.set(Calendar.MONTH, month - 1);
c.set(Calendar.YEAR, year);

System.out.println(c.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, new Locale("en", "US")).toUpperCase());












share|improve this question















marked as duplicate by Ole V.V. java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 24 at 13:12


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.













  • 1





    I recommend you don’t use Calendar. That class is poorly designed and long outdated. For your use you probably need LocalDate from java.time, the modern Java date and time API instead: LocalDate.of(year, month, day).

    – Ole V.V.
    Mar 24 at 10:24












  • By VS do you mean Visual Studio?? Could you show us your import statement?

    – Ole V.V.
    Mar 24 at 10:25







  • 1





    Can you reduce your code to a minimum that still reproduces the error and then include full source code? It sounds a lot like you're missing an import but can't be sure.

    – JussiV
    Mar 24 at 10:25






  • 3





    Don't name your class Calendar when you what do use java.util.Calendar!

    – Edwardth
    Mar 24 at 10:30











  • Easy and modern way: System.out.println(LocalDate.of(year, month, day).getDayOfWeek());. Prints for example SUNDAY..

    – Ole V.V.
    Mar 24 at 13:16













0












0








0









This question already has an answer here:



  • Method undefined for type Java

    1 answer



  • What does a “Cannot find symbol” compilation error mean?

    10 answers



I am getting error for cannot find symbol



getInstance(),Calendar.DATE,Calendar.MONTH,Calendar.YEAR



This only occurs when I am running offline on VS Code.
On running in on an online IDE (Hacker Rank), I get compilation successful.
JDK 11 on desktop, JDK 8 on Hacker Rank.
I have tried running it on multiple IDEs and get compilation successful only on JDK 8



import java.util.*;
import java.lang.*;
import java.io.*;

class Calendar
public static void main(String[] args)
Scanner sc = new Scanner(System.in);
int day = sc.nextInt();
int month = sc.nextInt();
int year = sc.nextInt();
Calendar c = Calendar.getInstance();
c.set(Calendar.DATE, day);
c.set(Calendar.MONTH, month - 1);
c.set(Calendar.YEAR, year);

System.out.println(c.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, new Locale("en", "US")).toUpperCase());












share|improve this question

















This question already has an answer here:



  • Method undefined for type Java

    1 answer



  • What does a “Cannot find symbol” compilation error mean?

    10 answers



I am getting error for cannot find symbol



getInstance(),Calendar.DATE,Calendar.MONTH,Calendar.YEAR



This only occurs when I am running offline on VS Code.
On running in on an online IDE (Hacker Rank), I get compilation successful.
JDK 11 on desktop, JDK 8 on Hacker Rank.
I have tried running it on multiple IDEs and get compilation successful only on JDK 8



import java.util.*;
import java.lang.*;
import java.io.*;

class Calendar
public static void main(String[] args)
Scanner sc = new Scanner(System.in);
int day = sc.nextInt();
int month = sc.nextInt();
int year = sc.nextInt();
Calendar c = Calendar.getInstance();
c.set(Calendar.DATE, day);
c.set(Calendar.MONTH, month - 1);
c.set(Calendar.YEAR, year);

System.out.println(c.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, new Locale("en", "US")).toUpperCase());







This question already has an answer here:



  • Method undefined for type Java

    1 answer



  • What does a “Cannot find symbol” compilation error mean?

    10 answers







java java.util.calendar






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 10:27







Nuruddin

















asked Mar 24 at 10:15









NuruddinNuruddin

33




33




marked as duplicate by Ole V.V. java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 24 at 13:12


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Ole V.V. java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 24 at 13:12


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









  • 1





    I recommend you don’t use Calendar. That class is poorly designed and long outdated. For your use you probably need LocalDate from java.time, the modern Java date and time API instead: LocalDate.of(year, month, day).

    – Ole V.V.
    Mar 24 at 10:24












  • By VS do you mean Visual Studio?? Could you show us your import statement?

    – Ole V.V.
    Mar 24 at 10:25







  • 1





    Can you reduce your code to a minimum that still reproduces the error and then include full source code? It sounds a lot like you're missing an import but can't be sure.

    – JussiV
    Mar 24 at 10:25






  • 3





    Don't name your class Calendar when you what do use java.util.Calendar!

    – Edwardth
    Mar 24 at 10:30











  • Easy and modern way: System.out.println(LocalDate.of(year, month, day).getDayOfWeek());. Prints for example SUNDAY..

    – Ole V.V.
    Mar 24 at 13:16












  • 1





    I recommend you don’t use Calendar. That class is poorly designed and long outdated. For your use you probably need LocalDate from java.time, the modern Java date and time API instead: LocalDate.of(year, month, day).

    – Ole V.V.
    Mar 24 at 10:24












  • By VS do you mean Visual Studio?? Could you show us your import statement?

    – Ole V.V.
    Mar 24 at 10:25







  • 1





    Can you reduce your code to a minimum that still reproduces the error and then include full source code? It sounds a lot like you're missing an import but can't be sure.

    – JussiV
    Mar 24 at 10:25






  • 3





    Don't name your class Calendar when you what do use java.util.Calendar!

    – Edwardth
    Mar 24 at 10:30











  • Easy and modern way: System.out.println(LocalDate.of(year, month, day).getDayOfWeek());. Prints for example SUNDAY..

    – Ole V.V.
    Mar 24 at 13:16







1




1





I recommend you don’t use Calendar. That class is poorly designed and long outdated. For your use you probably need LocalDate from java.time, the modern Java date and time API instead: LocalDate.of(year, month, day).

– Ole V.V.
Mar 24 at 10:24






I recommend you don’t use Calendar. That class is poorly designed and long outdated. For your use you probably need LocalDate from java.time, the modern Java date and time API instead: LocalDate.of(year, month, day).

– Ole V.V.
Mar 24 at 10:24














By VS do you mean Visual Studio?? Could you show us your import statement?

– Ole V.V.
Mar 24 at 10:25






By VS do you mean Visual Studio?? Could you show us your import statement?

– Ole V.V.
Mar 24 at 10:25





1




1





Can you reduce your code to a minimum that still reproduces the error and then include full source code? It sounds a lot like you're missing an import but can't be sure.

– JussiV
Mar 24 at 10:25





Can you reduce your code to a minimum that still reproduces the error and then include full source code? It sounds a lot like you're missing an import but can't be sure.

– JussiV
Mar 24 at 10:25




3




3





Don't name your class Calendar when you what do use java.util.Calendar!

– Edwardth
Mar 24 at 10:30





Don't name your class Calendar when you what do use java.util.Calendar!

– Edwardth
Mar 24 at 10:30













Easy and modern way: System.out.println(LocalDate.of(year, month, day).getDayOfWeek());. Prints for example SUNDAY..

– Ole V.V.
Mar 24 at 13:16





Easy and modern way: System.out.println(LocalDate.of(year, month, day).getDayOfWeek());. Prints for example SUNDAY..

– Ole V.V.
Mar 24 at 13:16












1 Answer
1






active

oldest

votes


















2














Your problem is that you have named your class Calendar, and then are trying to use a system class named Calendar. Calling Calendar.getInstance() is failing to compile because the compiler is looking for a method named getInstance() to be defined in YOUR Calendar class. Name your class something else, and I think your code will compile and work fine.






share|improve this answer


















  • 1





    Also calling the Java until class with full name will work, like so: java.util.Calendar c = java.util.Calendar.getInstance(); ...

    – JussiV
    Mar 24 at 11:56

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Your problem is that you have named your class Calendar, and then are trying to use a system class named Calendar. Calling Calendar.getInstance() is failing to compile because the compiler is looking for a method named getInstance() to be defined in YOUR Calendar class. Name your class something else, and I think your code will compile and work fine.






share|improve this answer


















  • 1





    Also calling the Java until class with full name will work, like so: java.util.Calendar c = java.util.Calendar.getInstance(); ...

    – JussiV
    Mar 24 at 11:56















2














Your problem is that you have named your class Calendar, and then are trying to use a system class named Calendar. Calling Calendar.getInstance() is failing to compile because the compiler is looking for a method named getInstance() to be defined in YOUR Calendar class. Name your class something else, and I think your code will compile and work fine.






share|improve this answer


















  • 1





    Also calling the Java until class with full name will work, like so: java.util.Calendar c = java.util.Calendar.getInstance(); ...

    – JussiV
    Mar 24 at 11:56













2












2








2







Your problem is that you have named your class Calendar, and then are trying to use a system class named Calendar. Calling Calendar.getInstance() is failing to compile because the compiler is looking for a method named getInstance() to be defined in YOUR Calendar class. Name your class something else, and I think your code will compile and work fine.






share|improve this answer













Your problem is that you have named your class Calendar, and then are trying to use a system class named Calendar. Calling Calendar.getInstance() is failing to compile because the compiler is looking for a method named getInstance() to be defined in YOUR Calendar class. Name your class something else, and I think your code will compile and work fine.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 24 at 10:46









SteveSteve

3,9521728




3,9521728







  • 1





    Also calling the Java until class with full name will work, like so: java.util.Calendar c = java.util.Calendar.getInstance(); ...

    – JussiV
    Mar 24 at 11:56












  • 1





    Also calling the Java until class with full name will work, like so: java.util.Calendar c = java.util.Calendar.getInstance(); ...

    – JussiV
    Mar 24 at 11:56







1




1





Also calling the Java until class with full name will work, like so: java.util.Calendar c = java.util.Calendar.getInstance(); ...

– JussiV
Mar 24 at 11:56





Also calling the Java until class with full name will work, like so: java.util.Calendar c = java.util.Calendar.getInstance(); ...

– JussiV
Mar 24 at 11:56





Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript