1. Java : Sampel untuk mendapatkan tanggal esok hari

String dt = “2008-01-01″; // Start date
SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd”);
Calendar c = Calendar.getInstance();
c.setTime(sdf.parse(dt));
c.add(Calendar.DATE, 1); // number of days to add
dt = sdf.format(c.getTime()); // dt is now the new date

2.  PostgreSql : Sampel terkait modifikasi tanggal dengan character

- Untuk memperoleh tanggal esok hari

select now()+’1 days’ , * from tsemployee

- Get Current Date and Time using PostgreSQL now()
select now(); select now()::time; select now()::date;
select mydatefield::timestamp from mytable;

- Get Interval Between Two PostgreSQL Dates
select (now() – date_of_join) as days from employee ;
select (date_of_join – 7) as output from employee;

- Round the interval (above difference) to the nearest day using date_part()
select date_part(‘days’, now() – date_of_join) as days from employee;

- Breakdown the date interval into number of years, months and days using age()
select age(date_of_join) from employee;

- Retrieve any sub-fields from the Timestamp using PostgreSQL extract()
select extract(year from date_of_join) as output from employee;

- Truncate a particular date field using PostgreSQL date_trunc()
select date_trunc(‘month’,date_of_join) as output from employee ;
–> hasilnya : diperoleh tanggal awal bulan yang bersangkutan

- Display Postgresql Date in Various Format using to_char()
select to_char(date_of_join,’mm/dd/yy’) as output from employee;
select to_char(date_of_join, ‘FMMonth FMDDth’) as output from employee;
select to_char(startdate, ‘Dy (Day), Mon (Month)’) as output from employee;

- Convert String to Date using PostgreSQL to_timestamp()
select to_timestamp(’201024June10:12am’, ‘YYYYDDFMMonthHH12:MIam’) as valid_time;