Java SQL Date Get getDate(String aDate, int dif)

Here you can find the source of getDate(String aDate, int dif)

Description

get Date

License

Open Source License

Declaration

public static String getDate(String aDate, int dif) 

Method Source Code

//package com.java2s;
/**/*w  ww  . java 2s.  c  om*/
 * $RCSfile: DateUtil.java
 * $Revision: 1.0
 * $Date: Jan 30, 2011
 *
 * Copyright (C) 2010 SlFile, Inc. All rights reserved.
 *
 * This software is the proprietary information of SlFile, Inc.
 * Use is subject to license terms.
 */

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {
    public static String getDate(String aDate, int dif) {
        java.sql.Date date = null;
        try {
            date = java.sql.Date.valueOf(aDate);
        } catch (Exception e) {
            System.err.println("Application log:Catch Exception in getDate()");
            System.err.println("aDate:" + aDate);
            System.err.println(e.getMessage());
            e.printStackTrace();
            return null;
        }
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(5, dif);
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        String s = df.format(calendar.getTime());
        return s;
    }
}

Related

  1. getDate(ResultSet rs, int index)
  2. getDate(ResultSet rs, String colName)
  3. getDate(ResultSet rs, String column)
  4. getDate(ResultSet rs, String columnLabel)
  5. getDate(ResultSet rs, String columnName)
  6. getDate(String date)
  7. getDate(String date)
  8. getDate(String format)
  9. getDate(String pattern)