本文整理汇总了Java中java.util.SimpleTimeZone.setEndRule方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleTimeZone.setEndRule方法的具体用法?Java SimpleTimeZone.setEndRule怎么用?Java SimpleTimeZone.setEndRule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.SimpleTimeZone
的用法示例。
在下文中一共展示了SimpleTimeZone.setEndRule方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateTimeString
import java.util.SimpleTimeZone; //导入方法依赖的package包/类
public static String generateTimeString() {
StringBuilder guid = new StringBuilder();
// Create a calendar to get the date formatted properly
String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
Calendar calendar = new GregorianCalendar(pdt);
Date trialTime = new Date();
calendar.setTime(trialTime);
guid.append(calendar.get(Calendar.YEAR));
guid.append(calendar.get(Calendar.DAY_OF_YEAR));
guid.append(calendar.get(Calendar.HOUR_OF_DAY));
guid.append(calendar.get(Calendar.MINUTE));
guid.append(calendar.get(Calendar.SECOND));
guid.append(calendar.get(Calendar.MILLISECOND));
double random = Math.random();
guid.append(random);
return guid.toString();
}
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:23,代码来源:DOIDataCiteServiceBean.java
示例2: test_setEndRuleIIII
import java.util.SimpleTimeZone; //导入方法依赖的package包/类
/**
* @tests java.util.SimpleTimeZone#setEndRule(int, int, int, int)
*/
public void test_setEndRuleIIII() {
// Test for method void java.util.SimpleTimeZone.setEndRule(int, int,
// int, int)
SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
// Spec indicates that both end and start must be set or result is
// undefined
st.setStartRule(Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0);
st.setEndRule(Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
assertTrue("StartRule improperly set1", st.useDaylightTime());
assertTrue("StartRule improperly set2", st
.inDaylightTime(new GregorianCalendar(1998, Calendar.NOVEMBER,
13).getTime()));
assertTrue("StartRule improperly set3", !(st
.inDaylightTime(new GregorianCalendar(1998, Calendar.OCTOBER,
13).getTime())));
}
示例3: test_setEndRuleIIIIZ
import java.util.SimpleTimeZone; //导入方法依赖的package包/类
/**
* @tests java.util.SimpleTimeZone#setEndRule(int, int, int, int, boolean)
*/
public void test_setEndRuleIIIIZ() {
// Test for method void java.util.SimpleTimeZone.setEndRule(int, int,
// int, int, boolean)
SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
// Spec indicates that both end and start must be set or result is
// undefined
st.setStartRule(Calendar.NOVEMBER, 8, Calendar.SUNDAY, 1, false);
st.setEndRule(Calendar.NOVEMBER, 15, Calendar.SUNDAY, 1, true);
assertTrue("StartRule improperly set1", st.useDaylightTime());
assertTrue("StartRule improperly set2", st
.inDaylightTime((new GregorianCalendar(1999, Calendar.NOVEMBER,
7, 12, 0).getTime())));
assertTrue("StartRule improperly set3", st
.inDaylightTime((new GregorianCalendar(1999, Calendar.NOVEMBER,
20, 12, 0).getTime())));
assertTrue("StartRule improperly set4", !(st
.inDaylightTime(new GregorianCalendar(1999, Calendar.NOVEMBER,
6, 12, 0).getTime())));
assertTrue("StartRule improperly set5", !(st
.inDaylightTime(new GregorianCalendar(1999, Calendar.NOVEMBER,
21, 12, 0).getTime())));
}
示例4: test_setStartRuleIII
import java.util.SimpleTimeZone; //导入方法依赖的package包/类
/**
* @tests java.util.SimpleTimeZone#setStartRule(int, int, int)
*/
public void test_setStartRuleIII() {
// Test for method void java.util.SimpleTimeZone.setStartRule(int, int,
// int)
SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
// Spec indicates that both end and start must be set or result is
// undefined
st.setStartRule(Calendar.NOVEMBER, 1, 1);
st.setEndRule(Calendar.DECEMBER, 1, 1);
assertTrue("StartRule improperly set", st.useDaylightTime());
assertTrue("StartRule improperly set", st
.inDaylightTime((new GregorianCalendar(1998, Calendar.NOVEMBER,
13).getTime())));
assertTrue("StartRule improperly set", !(st
.inDaylightTime(new GregorianCalendar(1998, Calendar.OCTOBER,
13).getTime())));
}
示例5: test_setStartRuleIIII
import java.util.SimpleTimeZone; //导入方法依赖的package包/类
/**
* @tests java.util.SimpleTimeZone#setStartRule(int, int, int, int)
*/
public void test_setStartRuleIIII() {
// Test for method void java.util.SimpleTimeZone.setStartRule(int, int,
// int, int)
SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
// Spec indicates that both end and start must be set or result is
// undefined
st.setStartRule(Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0);
st.setEndRule(Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
assertTrue("StartRule improperly set1", st.useDaylightTime());
assertTrue("StartRule improperly set2", st
.inDaylightTime((new GregorianCalendar(1998, Calendar.NOVEMBER,
13).getTime())));
assertTrue("StartRule improperly set3", !(st
.inDaylightTime(new GregorianCalendar(1998, Calendar.OCTOBER,
13).getTime())));
}
示例6: test_setStartRuleIIIIZ
import java.util.SimpleTimeZone; //导入方法依赖的package包/类
/**
* @tests java.util.SimpleTimeZone#setStartRule(int, int, int, int, boolean)
*/
public void test_setStartRuleIIIIZ() {
// Test for method void java.util.SimpleTimeZone.setStartRule(int, int,
// int, int, boolean)
SimpleTimeZone st = new SimpleTimeZone(0, "Test");
// Spec indicates that both end and start must be set or result is
// undefined
st.setStartRule(Calendar.NOVEMBER, 1, Calendar.SUNDAY, 1, true);
st.setEndRule(Calendar.NOVEMBER, 15, Calendar.SUNDAY, 1, false);
assertTrue("StartRule improperly set1", st.useDaylightTime());
assertTrue("StartRule improperly set2", st
.inDaylightTime((new GregorianCalendar(1999, Calendar.NOVEMBER,
7, 12, 0).getTime())));
assertTrue("StartRule improperly set3", st
.inDaylightTime((new GregorianCalendar(1999, Calendar.NOVEMBER,
13, 12, 0).getTime())));
assertTrue("StartRule improperly set4", !(st
.inDaylightTime(new GregorianCalendar(1999, Calendar.NOVEMBER,
6, 12, 0).getTime())));
assertTrue("StartRule improperly set5", !(st
.inDaylightTime(new GregorianCalendar(1999, Calendar.NOVEMBER,
14, 12, 0).getTime())));
}
示例7: test_setStartYearI
import java.util.SimpleTimeZone; //导入方法依赖的package包/类
/**
* @tests java.util.SimpleTimeZone#setStartYear(int)
*/
public void test_setStartYearI() {
// Test for method void java.util.SimpleTimeZone.setStartYear(int)
SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
st.setStartRule(Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0);
st.setEndRule(Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
st.setStartYear(1999);
assertTrue("set year improperly set1", !(st
.inDaylightTime(new GregorianCalendar(1999, Calendar.JULY, 12)
.getTime())));
assertTrue("set year improperly set2", !(st
.inDaylightTime(new GregorianCalendar(1998, Calendar.OCTOBER,
13).getTime())));
assertTrue("set year improperly set3", (st
.inDaylightTime(new GregorianCalendar(1999, Calendar.NOVEMBER,
13).getTime())));
}
示例8: getReserveDate
import java.util.SimpleTimeZone; //导入方法依赖的package包/类
/**
* Calculates the reserve date.
*
* @param deliveryTime
* @return
*/
private Timestamp getReserveDate() {
final SimpleTimeZone mez = new SimpleTimeZone(+1 * 60 * 60 * 1000, "ECT");
mez.setStartRule(Calendar.MARCH, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
mez.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
final Calendar cal = GregorianCalendar.getInstance(mez);
// wenn nach x Uhr, einen Tag aufschlagen
// cal.add(Calendar.DAY_OF_MONTH, 1);
for (int i = 0; i < TIME_BEFORE_PROMISED; i++) {
cal.add(Calendar.DAY_OF_MONTH, 1);
final int weekday = cal.get(Calendar.DAY_OF_WEEK);
// wenn das promisedDate auf das Wochenende f�llt, auf Montag
// verschieben
if (weekday == 0) { // Sonntag
cal.add(Calendar.DAY_OF_MONTH, 1);
} else if (weekday == 7) { // Samstag
cal.add(Calendar.DAY_OF_MONTH, 2);
}
}
return new Timestamp(cal.getTimeInMillis());
}
示例9: test_setStartYearI
import java.util.SimpleTimeZone; //导入方法依赖的package包/类
/**
* @tests java.util.SimpleTimeZone#setStartYear(int)
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "setStartYear",
args = {int.class}
)
public void test_setStartYearI() {
// Test for method void java.util.SimpleTimeZone.setStartYear(int)
SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
st.setStartRule(Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0);
st.setEndRule(Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
st.setStartYear(1999);
assertTrue("set year improperly set1", !(st
.inDaylightTime(new GregorianCalendar(1999, Calendar.JULY, 12)
.getTime())));
assertTrue("set year improperly set2", !(st
.inDaylightTime(new GregorianCalendar(1998, Calendar.OCTOBER,
13).getTime())));
assertTrue("set year improperly set3", (st
.inDaylightTime(new GregorianCalendar(1999, Calendar.NOVEMBER,
13).getTime())));
}
示例10: test_useDaylightTime
import java.util.SimpleTimeZone; //导入方法依赖的package包/类
/**
* @tests java.util.SimpleTimeZone#useDaylightTime()
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "useDaylightTime",
args = {}
)
public void test_useDaylightTime() {
// Test for method boolean java.util.SimpleTimeZone.useDaylightTime()
SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
assertTrue("useDaylightTime returned incorrect value", !st
.useDaylightTime());
// Spec indicates that both end and start must be set or result is
// undefined
st.setStartRule(Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0);
st.setEndRule(Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
assertTrue("useDaylightTime returned incorrect value", st
.useDaylightTime());
}
示例11: Test4040996
import java.util.SimpleTimeZone; //导入方法依赖的package包/类
public void Test4040996() {
String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
pdt.setStartRule(APRIL, 1, SUNDAY, 2 * 60 * 60 * 1000);
pdt.setEndRule(OCTOBER, -1, SUNDAY, 2 * 60 * 60 * 1000);
Calendar calendar = new GregorianCalendar(pdt);
calendar.set(MONTH, 3);
calendar.set(DAY_OF_MONTH, 18);
calendar.set(SECOND, 30);
logln("MONTH: " + calendar.get(MONTH));
logln("DAY_OF_MONTH: "
+ calendar.get(DAY_OF_MONTH));
logln("MINUTE: " + calendar.get(MINUTE));
logln("SECOND: " + calendar.get(SECOND));
calendar.add(SECOND, 6);
//This will print out todays date for MONTH and DAY_OF_MONTH
//instead of the date it was set to.
//This happens when adding MILLISECOND or MINUTE also
logln("MONTH: " + calendar.get(MONTH));
logln("DAY_OF_MONTH: "
+ calendar.get(DAY_OF_MONTH));
logln("MINUTE: " + calendar.get(MINUTE));
logln("SECOND: " + calendar.get(SECOND));
if (calendar.get(MONTH) != 3
|| calendar.get(DAY_OF_MONTH) != 18
|| calendar.get(SECOND) != 36) {
errln("Fail: Calendar.add misbehaves");
}
}
示例12: generateYear
import java.util.SimpleTimeZone; //导入方法依赖的package包/类
public static String generateYear() {
StringBuilder guid = new StringBuilder();
// Create a calendar to get the date formatted properly
String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
Calendar calendar = new GregorianCalendar(pdt);
Date trialTime = new Date();
calendar.setTime(trialTime);
guid.append(calendar.get(Calendar.YEAR));
return guid.toString();
}
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:16,代码来源:DOIDataCiteServiceBean.java
示例13: test_useDaylightTime
import java.util.SimpleTimeZone; //导入方法依赖的package包/类
/**
* @tests java.util.SimpleTimeZone#useDaylightTime()
*/
public void test_useDaylightTime() {
// Test for method boolean java.util.SimpleTimeZone.useDaylightTime()
SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
assertTrue("useDaylightTime returned incorrect value", !st
.useDaylightTime());
// Spec indicates that both end and start must be set or result is
// undefined
st.setStartRule(Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0);
st.setEndRule(Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
assertTrue("useDaylightTime returned incorrect value", st
.useDaylightTime());
}
示例14: test_setDSTSavingsI
import java.util.SimpleTimeZone; //导入方法依赖的package包/类
/**
* @tests java.util.SimpleTimeZone#setDSTSavings(int)
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "setDSTSavings",
args = {int.class}
)
public void test_setDSTSavingsI() {
// Test for method void java.util.SimpleTimeZone.setDSTSavings(int)
SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
st.setStartRule(0, 1, 1, 1);
st.setEndRule(11, 1, 1, 1);
st.setDSTSavings(1);
assertEquals("Daylight savings amount not set", 1, st.getDSTSavings());
}
示例15: test_setDSTSavingsI
import java.util.SimpleTimeZone; //导入方法依赖的package包/类
/**
* @tests java.util.SimpleTimeZone#setDSTSavings(int)
*/
public void test_setDSTSavingsI() {
// Test for method void java.util.SimpleTimeZone.setDSTSavings(int)
SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
st.setStartRule(0, 1, 1, 1);
st.setEndRule(11, 1, 1, 1);
st.setDSTSavings(1);
assertEquals("Daylight savings amount not set", 1, st.getDSTSavings());
}