public static String addDate(String fromDate, String format, int addYear, int addMonth, int addDate, int addHour, int addMinute, int addSecond) throws ParseException {

    SimpleDateFormat sdf = new SimpleDateFormat(format);

    Date date = sdf.parse(fromDate);

    Calendar cal = new GregorianCalendar();


    cal.setTime(date);

    cal.add(Calendar.YEAR, +addYear);

    cal.add(Calendar.MONTH, +addMonth);

    cal.add(Calendar.DATE, +addDate);

    cal.add(Calendar.HOUR, +addHour);

    cal.add(Calendar.MINUTE, +addMinute);

    cal.add(Calendar.SECOND, +addSecond);


    SimpleDateFormat sdf2 = new SimpleDateFormat(format);

    String toDate = sdf2.format(cal.getTime());


    return toDate;

  }


  1년 후

  String addDate(format, "yyyy-MM-dd HH:mm:ss", 1, 0, 0, 0, 0, 0);

  10분 후

  String addDate(format, "yyyy-MM-dd HH:mm:ss", 0, 0, 0, 0, 10, 0);

FLAG_CANCEL_CURRENT : 이전에 생성한 PendingIntent 는 취소하고 새롭게 만든다.

FLAG_NO_CREATE : 생성된 PendingIntent 를 반환한다. 재사용 가능하다.

FLAG_ONE_SHOT : 이 flag 로 생성한 PendingIntent 는 일회용이다.

FLAG_UPDATE_CURRENT : 이미 생성된 PendingIntent 가 존재하면 해당 Intent 의 내용을 변경한다.


출처: http://mission12.tistory.com/89 [제자와 나눔]

http://www.dpriver.com/pp/sqlformat.htm

'기타' 카테고리의 다른 글

material develop android site  (0) 2021.07.28
유니코드 변환  (0) 2020.08.05
codebeautify  (0) 2017.12.02
맥 터미널 개발환경 구축하기  (0) 2017.12.02
나인패치 이미지 사이트  (0) 2017.12.02

+ Recent posts