-1
import java.time.*;  
public class ZoneIdExample1 {  
  public static void main(String... args) {  
    ZoneId zoneid1 = ZoneId.of("Asia/Kolkata");  
    ZoneId zoneid2 = ZoneId.of("Asia/Tokyo");  
    LocalTime id1 = LocalTime.now(zoneid1);  
    LocalTime id2 = LocalTime.now(zoneid2);  
    System.out.println(id1);  
    System.out.println(id2);  
    System.out.println(id1.isBefore(id2));    
  }  
}  

Exception in thread "main" java.lang.Error: Unresolved compilation problem:

    at ZoneIdExample1.main(time.java:3)

Please help me to resolve this error.

  • It is working fine locally.. – Sabareesh Muralidharan Jun 28 '20 at 02:13
  • 1
    have you checked whether your IDE has a correct JDK mapped? – Sabareesh Muralidharan Jun 28 '20 at 04:00
  • Please help us help you. Your IDE or compiler is issuing one or more error messages before you even try to run your program. Quote those in the question, please, or just the first one. I am sure we can make some sense of it and help you on. – Ole V.V. Jun 30 '20 at 20:45
  • Does this answer your question? [Java: Unresolved compilation problem](https://stackoverflow.com/questions/1124788/java-unresolved-compilation-problem), Search for more similar questions. – Ole V.V. Jun 30 '20 at 20:46

1 Answers1

0

This works exactly as written on my machine. I am using jdk-14. I suspect you are using an older version of JAVA.

If you try changing the third line to use String[] instead of String... it is likely to fix the issue.

import java.time.*;  
public class ZoneIdExample1 {  
  public static void main(String[] args) {  
    ZoneId zoneid1 = ZoneId.of("Asia/Kolkata");  
    ZoneId zoneid2 = ZoneId.of("Asia/Tokyo");  
    LocalTime id1 = LocalTime.now(zoneid1);  
    LocalTime id2 = LocalTime.now(zoneid2);  
    System.out.println(id1);  
    System.out.println(id2);  
    System.out.println(id1.isBefore(id2));    
  }  
}  
  • Do you think that would be a problem?? before hitting a downvote, I just wanted to confirm tho' – Sabareesh Muralidharan Jun 28 '20 at 02:23
  • I think it is likely to be a problem on an older version of java. He definitely had an exception in the original question. – Maggiedageek Jun 28 '20 at 02:32
  • @mudit2703 Is it the same error message, though? Varargs (triple dot) was introduced in 1.5 and java.time was introduce in 1.8. – Febtober Jun 28 '20 at 09:53
  • @mudit2703 To be more specific, would it be possible that Maggiedageek's solution took care of the issue with varargs (triple dot), and now it's a different issue that java.time is not available? (implies you are running jdk 1.4 or earlier?) – Febtober Jun 28 '20 at 09:59