Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.mycompany.login.mb; import java.util.Date; import org.joda.time.DateTime; import org.joda.time.LocalDate; import org.joda.time.LocalDateTime; import org.joda.time.format.DateTimeFormatter; import org.joda.time.format.DateTimeFormatterBuilder; /** * * @author anderson.freitas */ public class DateBean { //formato YYYY-MM-dd public LocalDate getDateInicial() { Date date = new Date(); LocalDate datainicial = new LocalDate(date); return datainicial; } //formato YYYY-MM-dd public LocalDate getDateFinal() { Date date = new Date(); LocalDate datafinal = new LocalDate(date); return datafinal; } /* public String formataData(DateTime data) { return data.toString("YYYY-MM-dd HH:mm"); } */ public static void main(String[] args) { Date date = new Date(); DateTime dateTime = new DateTime(date); DateTime dateTeste = new DateTime(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), dateTime.getHourOfDay(), dateTime.getMinuteOfHour()); // System.out.println("ANO: " + dateTime.getYear()); // System.out.println("MES: " + dateTime.getMonthOfYear()); // System.out.println("DIA: " + dateTime.getDayOfMonth()); // System.out.println("HORA: " + dateTime.getHourOfDay()); // System.out.println("MINUTO: " + dateTime.getMinuteOfHour()); // System.out.println("Data Formatada:" + dateTime.getYear() + "/" + dateTime.getMonthOfYear() + "/" + dateTime.getDayOfMonth()); //System.out.println(dateTeste.toString("YYYY-MM-dd HH:mm")); LocalDate local = new LocalDate(date); System.out.println("Local Date: " + local); } }