Here you can find the source of convertDateToRpcFormat(Date date)
Parameter | Description |
---|---|
date | a parameter |
public static String convertDateToRpcFormat(Date date)
//package com.java2s; //License from project: Apache License import java.text.DecimalFormat; import java.util.Calendar; import java.util.Date; public class Main { /**/*from w w w . j a v a2 s. c o m*/ * * @param date * @return - a String representation of the date in the format needed to make * an RPC call or a zero-length string if date is null. */ public static String convertDateToRpcFormat(Date date) { if (date == null) return ""; Calendar calendar = Calendar.getInstance(); calendar.setTime(date); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH) + 1; int day = calendar.get(Calendar.DAY_OF_MONTH); // int hour = calendar.get(Calendar.HOUR_OF_DAY); // int minute = calendar.get(Calendar.MINUTE); //int second = calendar.get(Calendar.SECOND); String mDateFormat = ""; /* int yearDifference = ((year - 1700) / 100); mDateFormat = yearDifference + ""; year = (year % 100); */ DecimalFormat twoDigitFormat = new DecimalFormat("00"); mDateFormat = twoDigitFormat.format(month) + "/" + twoDigitFormat.format(day) + "/" + year; /* mDateFormat += twoDigitFormat.format(year) + twoDigitFormat.format(month) + twoDigitFormat.format(day) + twoDigitFormat.format(hour) + twoDigitFormat.format(minute) + twoDigitFormat.format(second); */ return mDateFormat; } }