Solved Get Calendar

Discussion in 'Plugin Development' started by TheEnderCrafter9, Jun 19, 2017.

Thread Status:
Not open for further replies.
  1. Hi, I have been trying to find a way to get the current date in my plugin.

    This is my code:
    Code:
      Calendar cal = Calendar.getInstance();
    
        if (args[0].equalsIgnoreCase("Age")) {
           int year = 0, month = 0, day = 0;
           if ((cal.get(Calendar.YEAR) - 2016) < 0) {
             System.out.print(year);
             year = 0;
           }
           if ((cal.get(Calendar.MONTH) - 2016) < 0) {
             System.out.print(month);
             month = 0;
           }
           if ((cal.get(Calendar.DAY_OF_MONTH) - 2016) < 0) {
             System.out.print(day);
             day = 0;
           }
    
           sender.sendMessage(l.getPlugMsg() + ChatColor.WHITE + "This server is " + l.getDarkColor() + year
               + ChatColor.WHITE + " years old, " + l.getDarkColor() + month + ChatColor.WHITE + " months old, "
               + l.getDarkColor() + day + ChatColor.WHITE + " and days old.");
           return true;
         }
    
    According to https://stackoverflow.com/questions/7226156/how-to-get-day-of-the-month?answertab=active#tab-top My code would work.

    How would I get the current Day of Year, Month and Year within bukkit?
     
  2. Offline

    Caderape2

Thread Status:
Not open for further replies.

Share This Page