Java SQL Time Calculate getMonth(String dateTime)

Here you can find the source of getMonth(String dateTime)

Description

get Month

License

Apache License

Declaration

@SuppressWarnings("static-access")
    public static int getMonth(String dateTime) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.sql.Timestamp;

import java.text.SimpleDateFormat;

import java.util.Calendar;
import java.util.Date;

public class Main {
    @SuppressWarnings("static-access")
    public static int getMonth(String dateTime) {
        Calendar c = Calendar.getInstance();
        c.setTime(getDateTime(dateTime));
        int month = c.get(c.MONTH) + 1;
        return month;
    }//  w  ww  .j ava  2  s.  co  m

    public static Timestamp getDateTime() {
        return Timestamp.valueOf(getFormatDate("yyyy-MM-dd HH:mm:ss"));
    }

    public static Timestamp getDateTime(String datetime) {
        return Timestamp.valueOf(datetime);
    }

    protected static String getFormatDate(String formatString) {
        String currentDate = "";
        SimpleDateFormat format1 = new SimpleDateFormat(formatString);
        currentDate = format1.format(new Date());
        return currentDate;
    }
}

Related

  1. getDifference(Time timeFrom, Time timeTo)
  2. getDiffTime(String _fromDate, String _fromTime, String _toDate, String _toTime)
  3. getExpiresTime(Long validityPeriod)
  4. getMidNightTime()
  5. getMinute(Time time)
  6. getMonth(String dateTime)
  7. getNewFileList(String path, String mintime)
  8. getNextDateTimeStr(String format)
  9. getNurseCoverageEndTime(Time startTime, Time shiftLength)